1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-22 12:30:41 +00:00

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 ; Constants
SCREEN_XSIZE = 40 ; screen columns
SCREEN_YSIZE = 28 ; screen rows
FUNCTKEY = $A5
FNAME_LEN = 16 ; maximum length of file-name FNAME_LEN = 16 ; maximum length of file-name
@ -19,14 +24,22 @@ BASIC_BUF := $35
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; Low memory ; Low memory
MODEKEY := $0209
CAPSLOCK := $020C CAPSLOCK := $020C
PATTERN := $0213 PATTERN := $0213
IRQVec := $0245 IRQVec := $0245
JOINFLAG := $025A ; 0 = don't joiu, $4A = join BASIC programs
VERIFYFLAG := $025B ; 0 = load, 1 = verify
CURS_Y := $0268 CURS_Y := $0268
CURS_X := $0269 CURS_X := $0269
STATUS := $026A STATUS := $026A
TIMER3 := $0276 TIMER3 := $0276
CFILE_NAME := $027F
CFOUND_NAME := $0293 CFOUND_NAME := $0293
FILESTART := $02A9
FILEEND := $02AB
AUTORUN := $02AD ; $00 = only load, $C7 = autorun
LANGFLAG := $02AE ; $00 = BASIC, $80 = machine code
KEYBUF := $02DF KEYBUF := $02DF
PARAM1 := $02E1 ; & $02E2 PARAM1 := $02E1 ; & $02E2
PARAM2 := $02E3 ; & $02E4 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 ; Screen size variables
; ;
.export screensize .export screensize
.include "atmos.inc"
.proc screensize .proc screensize
ldx #40 ldx #SCREEN_XSIZE
ldy #28 ldy #SCREEN_YSIZE
rts rts
.endproc .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); ; void __fastcall__ atmos_load(const char* name);
.export _atmos_load .export _atmos_load
.import store_filename .import store_filename
.include "atmos.inc"
.proc _atmos_load .proc _atmos_load
sei sei
jsr store_filename jsr store_filename
ldx #$00 ldx #$00
stx $02ad stx AUTORUN ; don't try to run the file
stx $02ae stx LANGFLAG ; BASIC
stx $025a stx JOINFLAG ; don't join it to another BASIC program
stx $025b stx VERIFYFLAG ; load the file
jsr cload_bit jsr cload_bit
cli cli
rts 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); ; void __fastcall__ atmos_save(const char* name, const void* start, const void* end);
.export _atmos_save .export _atmos_save
.import popax, store_filename .import popax, store_filename
.include "atmos.inc"
.proc _atmos_save .proc _atmos_save
sei sei
sta $02ab ; file end lo sta FILEEND
stx $02ac ; file end hi stx FILEEND+1
jsr popax jsr popax
sta $02a9 ; file start lo sta FILESTART
stx $02aa ; file start hi stx FILESTART+1
jsr popax jsr popax
jsr store_filename jsr store_filename
lda #00 lda #00
sta $02ad sta AUTORUN
jsr csave_bit jsr csave_bit
cli cli
rts 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); ; char cgetc (void);
; ;
@ -11,7 +12,6 @@
.include "atmos.inc" .include "atmos.inc"
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------
; ;
@ -41,8 +41,8 @@
@L2: and #$7F ; Mask out avail flag @L2: and #$7F ; Mask out avail flag
sta KEYBUF sta KEYBUF
ldy $209 ldy MODEKEY
cpy #$A5 cpy #FUNCTKEY
bne @L3 bne @L3
ora #$80 ; FUNCT pressed 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 .export _clrscr
@ -27,7 +28,7 @@
; Clear full pages. Y is still zero ; Clear full pages. Y is still zero
ldx #>(28*40) ldx #>(SCREEN_YSIZE * SCREEN_XSIZE)
lda #' ' lda #' '
@L1: sta (ptr2),y @L1: sta (ptr2),y
iny ; Bump low byte of address iny ; Bump low byte of address
@ -40,7 +41,7 @@
@L2: sta (ptr2),y @L2: sta (ptr2),y
iny iny
cpy #<(28*40) cpy #<(SCREEN_YSIZE * SCREEN_XSIZE)
bne @L2 bne @L2
rts 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 cputcxy (unsigned char x, unsigned char y, char c);
; void cputc (char c); ; void cputc (char c);
@ -41,7 +42,7 @@ output:
advance: advance:
iny iny
cpy #40 cpy #SCREEN_XSIZE
bne L3 bne L3
inc CURS_Y ; new line inc CURS_Y ; new line
ldy #0 ; + cr ldy #0 ; + cr
@ -85,12 +86,12 @@ L3: sty CURS_X
.rodata .rodata
ScrTabLo: ScrTabLo:
.repeat 28, Line .repeat SCREEN_YSIZE, Line
.byte <(SCREEN + Line * 40) .byte <(SCREEN + Line * SCREEN_XSIZE)
.endrep .endrep
ScrTabHi: ScrTabHi:
.repeat 28, Line .repeat SCREEN_YSIZE, Line
.byte >(SCREEN + Line * 40) .byte >(SCREEN + Line * SCREEN_XSIZE)
.endrep .endrep

View File

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

View File

@ -2,7 +2,7 @@
; Graphics driver for the 240x200x2 monochrome mode on the Atmos ; Graphics driver for the 240x200x2 monochrome mode on the Atmos
; ;
; Stefan Haubenthal <polluks@sdf.lonestar.org> ; 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" .include "zeropage.inc"
@ -158,7 +158,7 @@ GETERROR:
; ;
CONTROL: CONTROL:
sta $213 sta PATTERN
lda #TGI_ERR_OK lda #TGI_ERR_OK
sta ERROR sta ERROR
rts rts