Hello, I'm Restarting ZX81 Programming After... 30 Years

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
IanB
Posts: 60
Joined: Mon Jul 27, 2015 5:40 am
Location: Northampton UK

Re: Hello, I'm Restarting ZX81 Programming After... 30 Years

Post by IanB »

Yes, I think I'm getting the hang of it now. I just had trouble getting it to compile when I removed the "include" for the Display File, until I looked at the structure of the files and saw better how they function. This is just a test program (it does nothing of any great use except print to the display);

Code: Select all

format zx81
;labelusenumeric
;LISTON

        // hardware options to be set and change defaults in ZX81DEF.INC
        MEMAVL     =       MEM_1K         // can be MEM_1K, MEM_2K, MEM_4K, MEM_8K, MEM_16K, MEM_32K, MEM_48K
                                           // default value is MEM_16K
        STARTMODE  EQU     SLOW_MODE       // SLOW or FAST
        DFILETYPE  EQU     AUTO          // COLLAPSED or EXPANDED or AUTO
        STARTUPMSG EQU     '' // any message will be shown on screen after loading, max. 32 chars

        include '..\SINCL-ZX\ZX81.INC'        // definitions of constants

AUTORUN:
RAND USR _hide #start

start:
        ld hl, (D_FILE)
        ld de,0009
        add hl,de
        ld c,$10
loop0:
        ld b,$20
loop1:
        bit 6, (hl)
        jr z, nohalt
        inc hl
nohalt:
        ld a,$82
        ld (hl),a
        inc hl
        djnz loop1
        dec c
        jr nz, loop0
loop2:
        jr loop2

DFILE_ADDR:
//        include '..\SINCL-ZX\ZX81DISP.INC'          ; include D_FILE and needed memory areas
         db NEWLINE
         db 6 dup($1C),NEWLINE
         db NEWLINE
Main_Screen:
         repeat 20
                db 32 dup(0),NEWLINE
         end repeat
         db 2 dup (NEWLINE)

VARS_ADDR:
        db 80h
WORKSPACE:
-but I think this is about right, yes?
User avatar
PokeMon
Posts: 2264
Joined: Sat Sep 17, 2011 6:48 pm

Re: Hello, I'm Restarting ZX81 Programming After... 30 Years

Post by PokeMon »

Not sure - does it work ? If yes it's okay. :mrgreen:
IanB
Posts: 60
Joined: Mon Jul 27, 2015 5:40 am
Location: Northampton UK

Re: Hello, I'm Restarting ZX81 Programming After... 30 Years

Post by IanB »

Yes it does. It's just the display file bit at the end that mattered, not the machine code :)
User avatar
PokeMon
Posts: 2264
Joined: Sat Sep 17, 2011 6:48 pm

Re: Hello, I'm Restarting ZX81 Programming After... 30 Years

Post by PokeMon »

By the way - you might avoid empty lines with just space filled as this takes much space in your 1k memory.
Empty lines consist of just the NEWLINE char.
If you have 20 lines with 32 blank chars this would take 640 bytes of 1k - quite much.
The trick is to have a smaller display area to have more space for code. 8-)
User avatar
PokeMon
Posts: 2264
Joined: Sat Sep 17, 2011 6:48 pm

Re: Hello, I'm Restarting ZX81 Programming After... 30 Years

Post by PokeMon »

IanB wrote:Yes it does. It's just the display file bit at the end that mattered, not the machine code :)
Didn't try out yet - what matter exactly ?
IanB
Posts: 60
Joined: Mon Jul 27, 2015 5:40 am
Location: Northampton UK

Re: Hello, I'm Restarting ZX81 Programming After... 30 Years

Post by IanB »

It was just to show you how I'd worked out how to set up my own display file ;)

Yes, I know about saving space with unexpanded lines, I'm already planning cunning things with that :)
User avatar
PokeMon
Posts: 2264
Joined: Sat Sep 17, 2011 6:48 pm

Re: Hello, I'm Restarting ZX81 Programming After... 30 Years

Post by PokeMon »

Okay, great. Look nice. 8-)
Clipboard01.jpg
Clipboard01.jpg (50.65 KiB) Viewed 2731 times
dr beep
Posts: 2080
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: Hello, I'm Restarting ZX81 Programming After... 30 Years

Post by dr beep »

This is my smallest source to start a MC program.
I added some effects (wait for key and print) to show that BASIC is overwritten from screen.

After loading the screen will tremble due to the command in BASIC to start MC, but after pressing a key CLS follows.
With Hires you can 'kill' the entire screen, no lowres defintion needed at all.
You only need to make your own program.

SYSVAR with X are preferably left unchanged

Code: Select all

                                                                
                                                                
           ORG  #4009                                           
                                                                
           JP   begin             ; startroutine MC             
                                                                
d_file     DEFW dfile                                           
dfcc       DEFW dfile+1                                         
var        DEFW vars                                            
dest       DEFW 0                                               
eline      DEFW last                                            
chadd      DEFW last-1                                          
xptr       DEFW 0                                               
stkbot     DEFW last                                            
stkend     DEFW last              ; memory above reused from #4000 for data when NOT using ROM-routines like CLS
                                                                
berg       DEFB 0                 ; x                           
mem        DEFW 0                 ; x                           
           DEFB 0                                               
           DEFB 2                                               
           DEFW 1                                               
                                                                
lastk      DEFB 255,255,255       ; x                           
                                                                
margin     DEFB 55                ; x                           
nxtlin     DEFW basic                                           
count      DEFB 0                                               
picnr      DEFB 0                                               
flagx      DEFB 0                 ; x                           
strlen     DEFW 0                                               
                                                                
taddr      DEFW 3213              ; x                           
                                                                
seed       DEFW 0                                               
frames     DEFW 65535             ; x                           
coords     DEFB 0,0                                             
prcc       DEFB 188               ; x                           
sposn      DEFB 33,24             ; x                           
cdflag     DEFB 64                ; x                           
                                                                
begin      XOR  A                 ; start of code               
           IN   A,(254)           ; wait for a key to show error
           CPL                    ; screen                      
           AND  31                                              
           JR   Z,begin                                         
                                                                
           CALL #A2A              ; cls                         
                                                                
           LD   A,36              ; PRINT 8                     
           RST  16                                              
                                                                
loop       JR   loop              ; see fixed screen            
                                                                
                                                                
dfile      DEFB 118               ; BASIC MC Start ON SCREEN    
basic      DEFB 0,1               ; linenumber may be anything  
           DEFW 0                 ; length of BASIC irrelevant  
           DEFB 244,212,28        ; command usr                 
           DEFB 126               ; shortest FP-nr to #4009     
           DEFB 143,0,18                                        
           DEFB 118                            
                                                                
           DEFB 118,118,118,118,118,118,118,118,118             
           DEFB 118,118,118,118,118,118,118,118,118,118,118     
           DEFB 118,118,118    ; 25x HALT                   
                                                                
vars       DEFB 128               ; last obliged bytevalue      
                                                                
last       EQU  $                 ; last must point here.       

Post Reply