Replaced number literals in source code with meaningful symbol names.

This commit is contained in:
Greg King 2013-07-26 03:33:54 -04:00
parent 3574f3a742
commit f02843f05d
9 changed files with 62 additions and 33 deletions

View File

@ -7,6 +7,11 @@
; ---------------------------------------------------------------------------
; Constants
SCREEN_XSIZE = 40 ; screen columns
SCREEN_YSIZE = 28 ; screen rows
FUNCTKEY = $A5
FNAME_LEN = 16 ; maximum length of file-name
@ -19,14 +24,22 @@ BASIC_BUF := $35
; ---------------------------------------------------------------------------
; Low memory
MODEKEY := $0209
CAPSLOCK := $020C
PATTERN := $0213
IRQVec := $0245
JOINFLAG := $025A ; 0 = don't joiu, $4A = join BASIC programs
VERIFYFLAG := $025B ; 0 = load, 1 = verify
CURS_Y := $0268
CURS_X := $0269
STATUS := $026A
TIMER3 := $0276
CFILE_NAME := $027F
CFOUND_NAME := $0293
FILESTART := $02A9
FILEEND := $02AB
AUTORUN := $02AD ; $00 = only load, $C7 = autorun
LANGFLAG := $02AE ; $00 = BASIC, $80 = machine code
KEYBUF := $02DF
PARAM1 := $02E1 ; & $02E2
PARAM2 := $02E3 ; & $02E4

View File

@ -1,15 +1,17 @@
;
; Ullrich von Bassewitz, 2003-04-13
; 2003-04-13, Ullrich von Bassewitz
; 2013-07-16, Greg King
;
; Screen size variables
;
.export screensize
.include "atmos.inc"
.proc screensize
ldx #40
ldy #28
ldx #SCREEN_XSIZE
ldy #SCREEN_YSIZE
rts
.endproc

View File

@ -1,20 +1,24 @@
; Stefan Haubenthal, 2012-05-06
; based on code by Twilighte
; Based on code by Twilighte.
; 2012-05-06, Stefan Haubenthal
; 2013-07-22, Greg King
;
; void __fastcall__ atmos_load(const char* name);
.export _atmos_load
.import store_filename
.include "atmos.inc"
.proc _atmos_load
sei
jsr store_filename
ldx #$00
stx $02ad
stx $02ae
stx $025a
stx $025b
stx AUTORUN ; don't try to run the file
stx LANGFLAG ; BASIC
stx JOINFLAG ; don't join it to another BASIC program
stx VERIFYFLAG ; load the file
jsr cload_bit
cli
rts

View File

@ -1,23 +1,27 @@
; Stefan Haubenthal, 2012-05-06
; based on code by Twilighte
; Based on code by Twilighte.
; 2012-05-06, Stefan Haubenthal
; 2013-07-22, Greg King
;
; void __fastcall__ atmos_save(const char* name, const void* start, const void* end);
.export _atmos_save
.import popax, store_filename
.include "atmos.inc"
.proc _atmos_save
sei
sta $02ab ; file end lo
stx $02ac ; file end hi
sta FILEEND
stx FILEEND+1
jsr popax
sta $02a9 ; file start lo
stx $02aa ; file start hi
sta FILESTART
stx FILESTART+1
jsr popax
jsr store_filename
lda #00
sta $02ad
sta AUTORUN
jsr csave_bit
cli
rts

View File

@ -1,5 +1,6 @@
;
; Ullrich von Bassewitz, 2003-04-13
; 2003-04-13, Ullrich von Bassewitz
; 2013-07-26, Greg King
;
; char cgetc (void);
;
@ -11,7 +12,6 @@
.include "atmos.inc"
; ------------------------------------------------------------------------
;
@ -41,8 +41,8 @@
@L2: and #$7F ; Mask out avail flag
sta KEYBUF
ldy $209
cpy #$A5
ldy MODEKEY
cpy #FUNCTKEY
bne @L3
ora #$80 ; FUNCT pressed

View File

@ -1,5 +1,6 @@
;
; Ullrich von Bassewitz, 2003-04-13
; 2003-04-13, Ullrich von Bassewitz
; 2013-07-16, Greg King
;
.export _clrscr
@ -27,7 +28,7 @@
; Clear full pages. Y is still zero
ldx #>(28*40)
ldx #>(SCREEN_YSIZE * SCREEN_XSIZE)
lda #' '
@L1: sta (ptr2),y
iny ; Bump low byte of address
@ -40,7 +41,7 @@
@L2: sta (ptr2),y
iny
cpy #<(28*40)
cpy #<(SCREEN_YSIZE * SCREEN_XSIZE)
bne @L2
rts

View File

@ -1,5 +1,6 @@
;
; Ullrich von Bassewitz, 2003-04-13
; 2003-04-13, Ullrich von Bassewitz
; 2013-07-16, Greg King
;
; void cputcxy (unsigned char x, unsigned char y, char c);
; void cputc (char c);
@ -41,7 +42,7 @@ output:
advance:
iny
cpy #40
cpy #SCREEN_XSIZE
bne L3
inc CURS_Y ; new line
ldy #0 ; + cr
@ -85,12 +86,12 @@ L3: sty CURS_X
.rodata
ScrTabLo:
.repeat 28, Line
.byte <(SCREEN + Line * 40)
.repeat SCREEN_YSIZE, Line
.byte <(SCREEN + Line * SCREEN_XSIZE)
.endrep
ScrTabHi:
.repeat 28, Line
.byte >(SCREEN + Line * 40)
.repeat SCREEN_YSIZE, Line
.byte >(SCREEN + Line * SCREEN_XSIZE)
.endrep

View File

@ -1,12 +1,16 @@
; Helper function
.export store_filename
.importzp ptr1
.include "atmos.inc"
store_filename:
sta ptr1
stx ptr1+1
ldy #$0f ;store filename
ldy #FNAME_LEN - 1 ; store filename
: lda (ptr1),y
sta $027f,y
sta CFILE_NAME,y
dey
bpl :-
rts

View File

@ -2,7 +2,7 @@
; Graphics driver for the 240x200x2 monochrome mode on the Atmos
;
; Stefan Haubenthal <polluks@sdf.lonestar.org>
; 2013-07-15, Greg King <gregdk@users.sf.net>
; 2013-07-16, Greg King <gregdk@users.sf.net>
;
.include "zeropage.inc"
@ -158,7 +158,7 @@ GETERROR:
;
CONTROL:
sta $213
sta PATTERN
lda #TGI_ERR_OK
sta ERROR
rts