Help needed to start writing ZX81 games...

General games-related topics

Re: Help needed to start writing ZX81 games...

Postby siggi on Mon Aug 31, 2009 9:05 am

Do you know the C-compiler Z88DK? So you could write games also in C.

It supports also the ZX81 (e. g. true HIRES (Wilf Rigter) and moving sprites) and a demo game shows how.

See
http://www.z88dk.org/wiki/doku.php/

and

http://www.z88dk.org/forum/forums.php


Siggi
There are 10 types of people in this world: those who understand binary and those who don't.
siggi
 
Posts: 159
Joined: Thu May 08, 2008 8:30 am
Location: Germany

Re: Help needed to start writing ZX81 games...

Postby XavSnap on Mon Aug 31, 2009 4:09 pm

Can't download EO !!! :shock:
The file must be trunkated...
User avatar
XavSnap
 
Posts: 244
Joined: Sat May 10, 2008 3:23 pm

Re: Help needed to start writing ZX81 games...

Postby sirmorris on Mon Aug 31, 2009 4:32 pm

http://www.rwapservices.co.uk/ZX80_ZX81/forums/viewtopic.php?f=4&t=67&p=461

This might be useful. It shows a cheeky technique for liberating the IY register for use in slow mode.

Let me know if I can be of any further help.

-Charlie
--=== ZXMMC - Modern all-in-one upgrade solution for stock ZX81 ===--
* SD/MMC storage * 32K Hires-capable RAM * Up to 32K EPROM * Reset button *
User avatar
sirmorris
 
Posts: 353
Joined: Thu May 08, 2008 4:45 pm
Location: oxon, uk

Re: Help needed to start writing ZX81 games...

Postby Moggy on Tue Sep 01, 2009 10:04 pm

Sir Morris
do us a favour put the soldering iron and vero board away and get coding again!!!
I thought Andre had some off-the-wall games ideas, this ones a little cracker (sprites on a zeddy yeees!!!)
You've done in m/l what he does in basic 10 out of 10.

Regards Moggy
Moggy
 
Posts: 82
Joined: Wed Jun 18, 2008 1:00 pm

Re: Help needed to start writing ZX81 games...

Postby BrunoFlorindo on Thu Sep 03, 2009 10:44 am

Nice to see Bob here! Maybe some of the current Speccy titles can have a ZX81 port? Ever since Mike Wynne was able to come up with a Speccy emulator for the Zeddy, I started to believe anything is possible! :D

And at some point, if possible, the new games could have optional AY sound. Not everyone has AY interfaces, but emulators would allow us to enjoy it. :)
User avatar
BrunoFlorindo
 
Posts: 193
Joined: Sat May 10, 2008 1:46 am
Location: Santa Ana, CA, USA

Re: Help needed to start writing ZX81 games...

Postby bobs on Thu Sep 03, 2009 5:53 pm

BrunoFlorindo wrote:Nice to see Bob here! Maybe some of the current Speccy titles can have a ZX81 port?


Just getting something on-screen in assembler will be nice to begin with! Once I've got into my stride though anything could happen.
User avatar
bobs
 
Posts: 73
Joined: Thu Aug 27, 2009 9:49 pm
Location: Derbyshire, UK

Re: Help needed to start writing ZX81 games...

Postby Colin on Thu Sep 17, 2009 12:25 am

Hi Bob,


I've just started playing with assembly language on an (emulated) ZX81. On a machine with an expanded display file (that is, on a machine with > 3KB RAM), the main thing to know is that there *must* be 25 Newline characters otherwise the machine will crash (or at least the display will become completely messed up).

The beginning of the display file is pointed to by the 16-bit value held at 16396 and 16397.

The first character must be a ZX81 newline character (decimal 118), this is followed by 32 display characters and then the line is terminated with another newline character. Each of the following lines is terminated by a newline character. Do not overwrite these characters by mistake!

I wrote the following routine for writing to the screen. You call MAKE_TABLE once at the beginning of your program, and then call PRINT_CHAR with a line, column and character value each time you want to put a character on screen. It uses a lookup table to hold the location of the first character of each line, and then adds the column position to get to the screen location.

I assemble this into a BIN file using the Pasmo assembler, then use a utility called BIN2P to transform that into a .P file with a BASIC loader ready to use in an emulator. (These tools are available for Linux, others will probably be able to advise what's best under Windows).

I'm very much a beginner at assembly language, so forgive anything that isn't clear or is suboptimal. The code is here, everyone please feel free to use it as you like:

Code: Select all
; Print Character Routine
;
; Prints a character at a
; specified print position.
;

;
; Entry point to print the character
;
; Registers:
; A   ->   Line
; B   ->   Column
; C   ->   Character to Print

PRINT_CHAR   LD   D, 00         ; Zero high byte of line counter

      ADD   A, A         ; Multiply line offset by two (2 bytes per line address)
      LD   E, A

      LD   HL, ADDRESS_TABLE   ; Point to beginning of screen address table
      ADD   HL, DE         ; Move pointer to address of beginning of screen line
      LD   E, (HL)         ; Store low byte of screen address
      INC   HL
      LD   D, (HL)         ; Store high byte of screen address
      EX   DE, HL         ; Place screen address into HL
      
      LD   D, 0            ; Put column position
      LD   E, B            ; into DE.
      ADD   HL, DE         ; Point HL to character position on line
      LD   (HL), C         ; Put character into display file
      RET

;      
; This routine only needs to be called once to create the screen line address table
;
MAKE_TABLE   LD   HL, ADDRESS_TABLE   ; Address table pointer
      LD   DE, (16396)      ; D_FILE
      INC   DE         ; Step over first control character
      LD   B, 24         ; Count 24 lines
TABLE_LOOP   LD   (HL), E         ; Store address of
      INC   HL         ; first character
      LD   (HL), D         ; of each screen line.
      INC   HL
      PUSH   BC
      LD   BC, 33         ; Add 33 characters
      EX   DE, HL         ; to screen address pointer
      ADD   HL, BC         ; (32 visible characters
      EX   DE, HL         ; plus newline)
      POP   BC
      DJNZ   TABLE_LOOP      ; Loop to process next line
      RET

ADDRESS_TABLE   DS   48         ; Reserve space for the 24 line addresses



Cheers,

Colin.
Colin
 
Posts: 1
Joined: Mon Sep 14, 2009 9:19 pm

Re: Help needed to start writing ZX81 games...

Postby thewiz on Fri Sep 18, 2009 9:39 am

Having read Colins message, I thought I would add how I handle screen address calculation. It might be a byte or two longer but doesn't need the table and takes the same amount of time regardless of coordinates. As I don't use basic once my M/c starts, the start of the display never moves so don't need to use (D_FILE).

Code: Select all
CALC    ld b, (xcoord) ; normally for player
        ld c, (ycord) ; normally for player
CALC0   ld h,0
        ld l,b
        push hl
        add hl,hl  ; x2
        add hl,hl  ; x4
        add hl,hl  ; x8
        add hl,hl  ; x16
        add hl,hl  ; x32
        pop de
        add hl,de ; x33
        ld e,c
        add hl,de
        ld de, <address of display + 1>
        add hl,de
        ld a,(hl) ; optional
        ret


I use the CALC0 entry point when b and c are set for another object, e.g. the enemy.

Enjoy
User avatar
thewiz
 
Posts: 32
Joined: Sun Aug 16, 2009 7:36 pm
Location: Crewe

Previous

Return to GAMES

Who is online

Users browsing this forum: No registered users and 0 guests