Make screensize() fetch the values dynamically instead of using variables

that are set on startup. This is needed to support the C128, which can switch
the screen size at runtime.


git-svn-id: svn://svn.cc65.org/cc65/trunk@2042 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2003-04-09 19:34:57 +00:00
parent 8632683f11
commit 37178d5141
25 changed files with 153 additions and 158 deletions

View File

@@ -4,12 +4,15 @@
; Screen size variables ; Screen size variables
; ;
.export xsize, ysize .export screensize
.rodata .include "apple2.inc"
xsize: .byte 40 .proc screensize
ysize: .byte 24
ldx #XSIZE
ldy #YSIZE
rts
.endproc

View File

@@ -20,6 +20,12 @@ MEMSIZE = $73 ; Highest free RAM location
BRKVec = $03F0 ; Break vector BRKVec = $03F0 ; Break vector
RESTOR = $03D0 ; Goto Dos RESTOR = $03D0 ; Goto Dos
; ---------------------------------------------------------------------------
; Screen size
XSIZE = 40
YSIZE = 24
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
; Hardware ; Hardware

View File

@@ -4,12 +4,14 @@
; Screen size variables ; Screen size variables
; ;
.export xsize, ysize .export screensize
.rodata .proc screensize
xsize: .byte 40
ysize: .byte 24
ldx #40
ldy #24
rts
.endproc

View File

@@ -4,26 +4,19 @@
; Screen size variables ; Screen size variables
; ;
.export xsize, ysize .export screensize
.import SCREEN
.constructor initscrsize .include "c128.inc"
.proc screensize
.code
ldx #40 ; Assume 40 column mode
initscrsize: bit MODE
jsr SCREEN bpl C40 ; Jump if 40 column mode
inx ldx #80
stx xsize C40: ldy #25
iny rts
sty ysize
rts .endproc
.bss
xsize: .res 1
ysize: .res 1

View File

@@ -4,22 +4,9 @@
; Screen size variables ; Screen size variables
; ;
.export xsize, ysize .export screensize
.import SCREEN .import SCREEN
.constructor initscrsize
screensize = SCREEN
.code
initscrsize:
jsr SCREEN
stx xsize
sty ysize
rts
.bss
xsize: .res 1
ysize: .res 1

View File

@@ -8,7 +8,6 @@
.export _cputcxy, _cputc, cputdirect, putchar .export _cputcxy, _cputc, cputdirect, putchar
.export newline, plot .export newline, plot
.import popa, _gotoxy .import popa, _gotoxy
.import xsize
.import PLOT .import PLOT
.include "../plus4/plus4.inc" .include "../plus4/plus4.inc"
@@ -50,7 +49,7 @@ cputdirect:
advance: advance:
iny iny
cpy xsize cpy #XSIZE
bne L3 bne L3
jsr newline ; new line jsr newline ; new line
ldy #0 ; + cr ldy #0 ; + cr
@@ -59,13 +58,13 @@ L3: sty CURS_X
newline: newline:
clc clc
lda xsize lda #XSIZE
adc SCREEN_PTR adc SCREEN_PTR
sta SCREEN_PTR sta SCREEN_PTR
bcc L4 bcc L4
inc SCREEN_PTR+1 inc SCREEN_PTR+1
clc clc
L4: lda xsize L4: lda #XSIZE
adc CRAM_PTR adc CRAM_PTR
sta CRAM_PTR sta CRAM_PTR
bcc L5 bcc L5

View File

@@ -4,22 +4,9 @@
; Screen size variables ; Screen size variables
; ;
.export xsize, ysize .export screensize
.import SCREEN .import SCREEN
.constructor initscrsize
screensize = SCREEN
.code
initscrsize:
jsr SCREEN
stx xsize
sty ysize
rts
.bss
xsize: .res 1
ysize: .res 1

View File

@@ -43,6 +43,12 @@ IRQVec = $0314
BRKVec = $0316 BRKVec = $0316
NMIVec = $0318 NMIVec = $0318
; ---------------------------------------------------------------------------
; Screen size
XSIZE = 40
YSIZE = 25
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; I/O: VIC ; I/O: VIC

View File

@@ -8,7 +8,6 @@
.export _cputcxy, _cputc, cputdirect, putchar .export _cputcxy, _cputc, cputdirect, putchar
.export newline, plot .export newline, plot
.import popa, _gotoxy .import popa, _gotoxy
.import xsize
.import PLOT .import PLOT
.include "c64.inc" .include "c64.inc"
@@ -50,7 +49,7 @@ cputdirect:
advance: advance:
iny iny
cpy xsize cpy #XSIZE
bne L3 bne L3
jsr newline ; new line jsr newline ; new line
ldy #0 ; + cr ldy #0 ; + cr
@@ -59,13 +58,13 @@ L3: sty CURS_X
newline: newline:
clc clc
lda xsize lda #XSIZE
adc SCREEN_PTR adc SCREEN_PTR
sta SCREEN_PTR sta SCREEN_PTR
bcc L4 bcc L4
inc SCREEN_PTR+1 inc SCREEN_PTR+1
clc clc
L4: lda xsize L4: lda #XSIZE
adc CRAM_PTR adc CRAM_PTR
sta CRAM_PTR sta CRAM_PTR
bcc L5 bcc L5

View File

@@ -4,12 +4,16 @@
; Screen size variables ; Screen size variables
; ;
.export xsize, ysize .export screensize
.rodata .include "cbm510.inc"
xsize: .byte 40
ysize: .byte 25
.proc screensize
ldx #XSIZE
ldy #YSIZE
rts
.endproc

View File

@@ -192,6 +192,12 @@ MoniSegSave = $03f0
wstvec = $03F8 wstvec = $03F8
WstFlag = $03FA ; Warm start flag WstFlag = $03FA ; Warm start flag
; ---------------------------------------------------------------------------
; Screen size
XSIZE = 40
YSIZE = 25
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
; I/O Definitions ; I/O Definitions

View File

@@ -10,7 +10,6 @@
.import PLOT .import PLOT
.import popa, _gotoxy .import popa, _gotoxy
.import xsize
.include "cbm510.inc" .include "cbm510.inc"
@@ -53,7 +52,7 @@ cputdirect:
advance: advance:
iny iny
cpy xsize cpy #XSIZE
bne L3 bne L3
jsr newline ; new line jsr newline ; new line
ldy #0 ; + cr ldy #0 ; + cr
@@ -62,13 +61,13 @@ L3: sty CURS_X
newline: newline:
clc clc
lda xsize lda #XSIZE
adc SCREEN_PTR adc SCREEN_PTR
sta SCREEN_PTR sta SCREEN_PTR
bcc L4 bcc L4
inc SCREEN_PTR+1 inc SCREEN_PTR+1
clc clc
L4: lda xsize L4: lda #XSIZE
adc CRAM_PTR adc CRAM_PTR
sta CRAM_PTR sta CRAM_PTR
bcc L5 bcc L5

View File

@@ -4,12 +4,16 @@
; Screen size variables ; Screen size variables
; ;
.export xsize, ysize .export screensize
.rodata .include "cbm610.inc"
xsize: .byte 80
ysize: .byte 25
.proc screensize
ldx #XSIZE
ldy #YSIZE
rts
.endproc

View File

@@ -187,6 +187,12 @@ wstvec = $03F8
WstFlag = $03FA ; Warm start flag WstFlag = $03FA ; Warm start flag
; ---------------------------------------------------------------------------
; Screen size
XSIZE = 80
YSIZE = 25
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; I/O definitions ; I/O definitions

View File

@@ -12,7 +12,6 @@
.import PLOT .import PLOT
.import _gotoxy .import _gotoxy
.import popa .import popa
.import xsize
.include "cbm610.inc" .include "cbm610.inc"
@@ -53,7 +52,7 @@ cputdirect:
advance: advance:
iny iny
cpy xsize cpy #XSIZE
bne L3 bne L3
jsr newline ; new line jsr newline ; new line
ldy #0 ; + cr ldy #0 ; + cr
@@ -62,7 +61,7 @@ L3: sty CURS_X
newline: newline:
clc clc
lda xsize lda #XSIZE
adc CharPtr adc CharPtr
sta CharPtr sta CharPtr
bcc L4 bcc L4

View File

@@ -6,24 +6,29 @@
.export _screensize .export _screensize
.import popax .import popsreg
.import xsize, ysize .import screensize
.importzp ptr1, ptr2 .importzp ptr1, sreg
.proc _screensize .proc _screensize
sta ptr1 ; Store the y pointer sta ptr1 ; Store the y pointer
stx ptr1+1 stx ptr1+1
jsr popsreg ; Get the x pointer into sreg
jsr screensize ; Get screensize into X/Y
tya ; Get Y size into A
jsr popax ; get the x pointer .IFP02
sta ptr2 ldy #0
stx ptr2+1 sta (ptr1),y
txa
sta (sreg),y
.ELSE
sta (ptr1)
txa
sta (sreg)
.ENDIF
ldy #0
lda xsize
sta (ptr2),y
lda ysize
sta (ptr1),y
rts rts
.endproc .endproc

View File

@@ -4,27 +4,16 @@
; Screen size variables ; Screen size variables
; ;
.export screensize
.export xsize, ysize
.constructor initscrsize
.include "pet.inc" .include "pet.inc"
.code .proc screensize
initscrsize:
ldx SCR_LINELEN ldx SCR_LINELEN
inx ; Variable is one less inx ; Variable is one less
stx xsize ldy #25
lda #25
sta ysize
rts rts
.endproc
.bss
xsize: .res 1
ysize: .res 1

View File

@@ -7,7 +7,6 @@
.export _clrscr .export _clrscr
.import plot .import plot
.importzp ptr1 .importzp ptr1
.import xsize
.include "pet.inc" .include "pet.inc"
@@ -23,9 +22,9 @@ _clrscr:
; Determine, how many pages to fill ; Determine, how many pages to fill
ldx #4 ldx #4
lda xsize lda SCR_LINELEN ; Check length of one line
cmp #40 cmp #40+1
beq L1 bcc L1
ldx #8 ldx #8
; Clear the screen ; Clear the screen

View File

@@ -8,10 +8,8 @@
.export _cputcxy, _cputc, cputdirect, putchar .export _cputcxy, _cputc, cputdirect, putchar
.export newline, plot .export newline, plot
.import popa, _gotoxy .import popa, _gotoxy
.import xsize
.include "pet.inc" .include "pet.inc"
; .include "../cbm/cbm.inc"
_cputcxy: _cputcxy:
pha ; Save C pha ; Save C
@@ -48,17 +46,17 @@ cputdirect:
; Advance cursor position ; Advance cursor position
advance: advance:
iny cpy SCR_LINELEN ; xsize-1
cpy xsize
bne L3 bne L3
jsr newline ; new line jsr newline ; new line
ldy #0 ; + cr ldy #$FF ; + cr
L3: sty CURS_X L3: iny
sty CURS_X
rts rts
newline: newline:
clc lda SCR_LINELEN ; xsize-1
lda xsize sec ; Account for -1 above
adc SCREEN_PTR adc SCREEN_PTR
sta SCREEN_PTR sta SCREEN_PTR
bcc L4 bcc L4
@@ -84,9 +82,9 @@ plot: ldy CURS_Y
lda ScrLo,y lda ScrLo,y
sta SCREEN_PTR sta SCREEN_PTR
lda ScrHi,y lda ScrHi,y
ldy xsize ldy SCR_LINELEN
cpy #40 cpy #40+1
beq @L1 bcc @L1
asl SCREEN_PTR ; 80 column mode asl SCREEN_PTR ; 80 column mode
rol a rol a
@L1: ora #$80 ; Screen at $8000 @L1: ora #$80 ; Screen at $8000

View File

@@ -4,11 +4,18 @@
; Screen size variables ; Screen size variables
; ;
.export xsize, ysize .export screensize
.data ; We will return the values directly instead of banking in the ROM and calling
; SCREEN which is a lot more overhead in code size and CPU cycles.
.proc screensize
ldx #40
ldy #25
rts
.endproc
xsize: .byte 40
ysize: .byte 25

View File

@@ -8,7 +8,6 @@
.export _cputcxy, _cputc, cputdirect, putchar .export _cputcxy, _cputc, cputdirect, putchar
.export newline, plot .export newline, plot
.import popa, _gotoxy .import popa, _gotoxy
.import xsize
.import PLOT .import PLOT
.include "plus4.inc" .include "plus4.inc"
@@ -50,7 +49,7 @@ cputdirect:
advance: advance:
iny iny
cpy xsize cpy #XSIZE
bne L3 bne L3
jsr newline ; new line jsr newline ; new line
ldy #0 ; + cr ldy #0 ; + cr
@@ -59,13 +58,13 @@ L3: sty CURS_X
newline: newline:
clc clc
lda xsize lda #XSIZE
adc SCREEN_PTR adc SCREEN_PTR
sta SCREEN_PTR sta SCREEN_PTR
bcc L4 bcc L4
inc SCREEN_PTR+1 inc SCREEN_PTR+1
clc clc
L4: lda xsize L4: lda #XSIZE
adc CRAM_PTR adc CRAM_PTR
sta CRAM_PTR sta CRAM_PTR
bcc L5 bcc L5

View File

@@ -41,6 +41,12 @@ IRQVec = $0314
BRKVec = $0316 BRKVec = $0316
NMIVec = $0318 NMIVec = $0318
; ---------------------------------------------------------------------------
; Screen size
XSIZE = 40
YSIZE = 25
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; I/O ; I/O

View File

@@ -4,22 +4,9 @@
; Screen size variables ; Screen size variables
; ;
.export xsize, ysize .export screensize
.import SCREEN .import SCREEN
.constructor initscrsize
screensize = SCREEN
.code
initscrsize:
jsr SCREEN
stx xsize
sty ysize
rts
.bss
xsize: .res 1
ysize: .res 1

View File

@@ -8,7 +8,6 @@
.export _cputcxy, _cputc, cputdirect, putchar .export _cputcxy, _cputc, cputdirect, putchar
.export newline, plot .export newline, plot
.import popa, _gotoxy .import popa, _gotoxy
.import xsize
.import PLOT .import PLOT
.include "vic20.inc" .include "vic20.inc"
@@ -50,7 +49,7 @@ cputdirect:
advance: advance:
iny iny
cpy xsize cpy #XSIZE
bne L3 bne L3
jsr newline ; new line jsr newline ; new line
ldy #0 ; + cr ldy #0 ; + cr
@@ -59,13 +58,13 @@ L3: sty CURS_X
newline: newline:
clc clc
lda xsize lda #XSIZE
adc SCREEN_PTR adc SCREEN_PTR
sta SCREEN_PTR sta SCREEN_PTR
bcc L4 bcc L4
inc SCREEN_PTR+1 inc SCREEN_PTR+1
clc clc
L4: lda xsize L4: lda #XSIZE
adc CRAM_PTR adc CRAM_PTR
sta CRAM_PTR sta CRAM_PTR
bcc L5 bcc L5

View File

@@ -28,6 +28,12 @@ CURS_COLOR = $287 ; Color under the cursor
PALFLAG = $2A6 ; $01 = PAL, $00 = NTSC PALFLAG = $2A6 ; $01 = PAL, $00 = NTSC
; ---------------------------------------------------------------------------
; Screen size
XSIZE = 22
YSIZE = 23
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; Kernal routines ; Kernal routines