From 679f5aa6756a5036e72259aa46fafbe2488610bc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stephan=20M=C3=BChlstrasser?= Date: Thu, 12 Feb 2015 20:54:47 +0100 Subject: [PATCH] Use constants for screen width and height. --- cfg/osic1p.cfg | 2 +- libsrc/osic1p/_scrsize.s | 8 +++----- libsrc/osic1p/cputc.s | 4 ++-- libsrc/osic1p/crt0.s | 7 ------- libsrc/osic1p/extzp.inc | 2 +- libsrc/osic1p/extzp.s | 3 +-- libsrc/osic1p/osic1p.inc | 2 ++ 7 files changed, 10 insertions(+), 18 deletions(-) diff --git a/cfg/osic1p.cfg b/cfg/osic1p.cfg index 59fdd34d8..4771639a6 100644 --- a/cfg/osic1p.cfg +++ b/cfg/osic1p.cfg @@ -7,7 +7,7 @@ SYMBOLS { } MEMORY { # for size of ZP see runtime/zeropage.s and c1p/extzp.s - ZP: file = "", define = yes, start = $0002, size = $001A + $0006; + ZP: file = "", define = yes, start = $0002, size = $001A + $0005; RAM: file = %O, define = yes, start = %S, size = __HIMEM__ - __STACKSIZE__ - %S; } SEGMENTS { diff --git a/libsrc/osic1p/_scrsize.s b/libsrc/osic1p/_scrsize.s index 3b0d71c2f..337fe1ee7 100644 --- a/libsrc/osic1p/_scrsize.s +++ b/libsrc/osic1p/_scrsize.s @@ -10,12 +10,10 @@ .export screensize .include "extzp.inc" + .include "osic1p.inc" .proc screensize - - ldx SCR_LINELEN - inx ; Variable is one less - ldy #25 + ldx #(SCR_LINELEN + 1) + ldy #(SCR_HEIGHT + 1) rts - .endproc diff --git a/libsrc/osic1p/cputc.s b/libsrc/osic1p/cputc.s index 9cea78789..f6f285301 100644 --- a/libsrc/osic1p/cputc.s +++ b/libsrc/osic1p/cputc.s @@ -35,7 +35,7 @@ cputdirect: ; Advance cursor position advance: - cpy SCR_LINELEN ; xsize-1 + cpy #SCR_LINELEN ; xsize-1 bne L3 jsr newline ; new line ldy #$FF ; + cr @@ -46,7 +46,7 @@ L3: iny newline: inc CURS_Y lda CURS_Y - cmp #24 ; screen height 25 lines hardcoded + cmp #SCR_HEIGHT ; screen height bne plot lda #0 ; wrap around to line 0 sta CURS_Y diff --git a/libsrc/osic1p/crt0.s b/libsrc/osic1p/crt0.s index 447b65c56..0db447bb0 100644 --- a/libsrc/osic1p/crt0.s +++ b/libsrc/osic1p/crt0.s @@ -28,13 +28,6 @@ _init: ldx #$FF ; Initialize stack pointer to $01FF txs cld ; Clear decimal mode -; --------------------------------------------------------------------------- -; Initialize screen width -; TODO: Can initialization be done in a more idiomatic way? -; TODO: Create function for changing screen width - lda #$18 - sta SCR_LINELEN - ; --------------------------------------------------------------------------- ; Set cc65 argument stack pointer diff --git a/libsrc/osic1p/extzp.inc b/libsrc/osic1p/extzp.inc index c5bb2b585..4aab34ff9 100644 --- a/libsrc/osic1p/extzp.inc +++ b/libsrc/osic1p/extzp.inc @@ -4,4 +4,4 @@ ; ------------------------------------------------------------------------ - .globalzp CURS_X, CURS_Y, CURS_SAV, SCR_LINELEN, SCREEN_PTR + .globalzp CURS_X, CURS_Y, CURS_SAV, SCREEN_PTR diff --git a/libsrc/osic1p/extzp.s b/libsrc/osic1p/extzp.s index dfa84a61c..95f9394dc 100644 --- a/libsrc/osic1p/extzp.s +++ b/libsrc/osic1p/extzp.s @@ -14,8 +14,7 @@ CURS_X: .byte 0 CURS_Y: .byte 0 CURS_SAV: .byte 0 -SCR_LINELEN: .byte 24 SCREEN_PTR: .res 2 -; size 6 +; size 5 ; Adjust size of this segment in osic1p.cfg if the size changes diff --git a/libsrc/osic1p/osic1p.inc b/libsrc/osic1p/osic1p.inc index e364277e0..58d63632f 100644 --- a/libsrc/osic1p/osic1p.inc +++ b/libsrc/osic1p/osic1p.inc @@ -5,3 +5,5 @@ RESET := $FF00 ; Reset address, show boot prompt ; Other definitions VIDEORAMSIZE = $0400 ; Size of C1P video RAM (1 kB) +SCR_LINELEN = $18 ; screen width - 1 +SCR_HEIGHT = $18 ; screen height - 1 -- 2.39.5