printString subroutine generalization

This commit is contained in:
giomba 2020-04-08 11:03:03 +02:00
parent 4498d045de
commit 977c3cf0e6
6 changed files with 48 additions and 48 deletions

View File

@ -2,15 +2,15 @@
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
gameover: gameover:
lda #<gameoverString lda #<gameoverString
sta printIntroString sta srcStringPointer
lda #>gameoverString lda #>gameoverString
sta printIntroString + 1 sta srcStringPointer + 1
lda #$00 lda #$00
sta introScreenStart sta dstScreenPointer
lda #$04 lda #$04
sta introScreenStart + 1 sta dstScreenPointer + 1
jsr printIntro jsr printString
; Set gameover and outro status ; Set gameover and outro status
lda #$ff lda #$ff

View File

@ -42,23 +42,23 @@ status1setSX:
status1okset: status1okset:
; Print "SNAKE BY GIOMBA" (see above for pointer details) ; Print "SNAKE BY GIOMBA" (see above for pointer details)
lda #<intro0string lda #<intro0string
sta printIntroString sta srcStringPointer
lda #>intro0string lda #>intro0string
sta printIntroString + 1 sta srcStringPointer + 1
; $0428 is 2nd line (previously filled with color shades by reset routine) ; $0428 is 2nd line (previously filled with color shades by reset routine)
lda #$28 lda #$28
clc clc
adc introX ; just add X, to make it look like it has moved adc introX ; just add X, to make it look like it has moved
sta introScreenStart sta dstScreenPointer
lda #$04 lda #$04
sta introScreenStart + 1 sta dstScreenPointer + 1
jsr printIntro jsr printString
; Print "PRESS SPACE TO PLAY" ; Print "PRESS SPACE TO PLAY"
lda #<intro1string lda #<intro1string
sta printIntroString sta srcStringPointer
lda #>intro1string lda #>intro1string
sta printIntroString + 1 sta srcStringPointer + 1
; $0478 is 4th line (previously filled with color shades by reset routine) ; $0478 is 4th line (previously filled with color shades by reset routine)
; add #19, then sub introX will make it move to other way of 2nd line ; add #19, then sub introX will make it move to other way of 2nd line
lda #$78 lda #$78
@ -66,10 +66,10 @@ status1okset:
adc #19 ; add #19 adc #19 ; add #19
sec sec
sbc introX ; sub introX sbc introX ; sub introX
sta introScreenStart sta dstScreenPointer
lda #$04 lda #$04
sta introScreenStart + 1 sta dstScreenPointer + 1
jsr printIntro jsr printString
; Some considerations on speed: ; Some considerations on speed:
; yes, maybe I should have put the string chars once in screen text memory ; yes, maybe I should have put the string chars once in screen text memory

View File

@ -22,25 +22,25 @@ introresetColorShade
; Print website ; Print website
lda #<intro2string ; lsb of string address lda #<intro2string ; lsb of string address
sta printIntroString ; put into lsb of source pointer sta srcStringPointer ; put into lsb of source pointer
lda #>intro2string ; do the same for msb of string address lda #>intro2string ; do the same for msb of string address
sta printIntroString + 1 ; put into msb of source pointer sta srcStringPointer + 1 ; put into msb of source pointer
lda #$26 ; this is lsb of address of 20th line lda #$26 ; this is lsb of address of 20th line
sta introScreenStart ; put into lsb of dest pointer sta dstScreenPointer ; put into lsb of dest pointer
lda #$07 ; do the same for msb of adress of 20th line lda #$07 ; do the same for msb of adress of 20th line
sta introScreenStart + 1 ; put into msb of dest pointer sta dstScreenPointer + 1 ; put into msb of dest pointer
jsr printIntro ; print jsr printString ; print
; Print Copyright ; Print Copyright
lda #<intro3string ; the assembly is the same as above, lda #<intro3string ; the assembly is the same as above,
sta printIntroString ; just change string to be printed sta srcStringPointer ; just change string to be printed
lda #>intro3string ; and line (21th line) lda #>intro3string ; and line (21th line)
sta printIntroString + 1 sta srcStringPointer + 1
lda #$58 lda #$58
sta introScreenStart sta dstScreenPointer
lda #$07 lda #$07
sta introScreenStart + 1 sta dstScreenPointer + 1
jsr printIntro jsr printString
rts rts

View File

@ -4,27 +4,27 @@ statusLevelTitle SUBROUTINE
; Print "Next Level" ; Print "Next Level"
lda #<levelIntroString lda #<levelIntroString
sta printIntroString sta srcStringPointer
lda #>levelIntroString lda #>levelIntroString
sta printIntroString + 1 sta srcStringPointer + 1
lda #$00 lda #$00
sta introScreenStart sta dstScreenPointer
lda #$04 lda #$04
sta introScreenStart + 1 sta dstScreenPointer + 1
jsr printIntro jsr printString
; Print level Title ; Print level Title
lda levelPointer lda levelPointer
sta printIntroString sta srcStringPointer
lda levelPointer + 1 lda levelPointer + 1
sta printIntroString + 1 sta srcStringPointer + 1
lda #$e2 lda #$e2
sta introScreenStart sta dstScreenPointer
lda #$05 lda #$05
sta introScreenStart + 1 sta dstScreenPointer + 1
jsr printIntro jsr printString
; advance level pointer, based on title string length ; advance level pointer, based on title string length
iny iny
@ -55,14 +55,14 @@ statusLevelLoad SUBROUTINE
; Set upper bar score/part text ; Set upper bar score/part text
lda #<scoreString lda #<scoreString
sta printIntroString sta srcStringPointer
lda #>scoreString lda #>scoreString
sta printIntroString + 1 sta srcStringPointer + 1
lda #$14 lda #$14
sta introScreenStart sta dstScreenPointer
lda #$04 lda #$04
sta introScreenStart + 1 sta dstScreenPointer + 1
jsr printIntro jsr printString
; Set score ; Set score
ldy #26 ldy #26

View File

@ -87,16 +87,16 @@ printByte SUBROUTINE
rts rts
printIntro SUBROUTINE printString SUBROUTINE
; Print string for intro ; Print string
; Input parameters: ; Input parameters:
; printIntroString pointer to string to be printed (source) ; srcStringPointer pointer to string to be printed (source)
; introScreenStart pointer to text video memory on screen where to print (dest) ; dstScreenPointer pointer to text video memory on screen where to print (dest)
; Output results: ; Output results:
; Y leaves string length in reg Y ; Y leaves string length in reg Y
ldy #0 ldy #0
.loop: .loop:
lda (printIntroString),y ; get char from string lda (srcStringPointer),y ; get char from string
beq .end ; if zero, then end (string must be null-terminated) beq .end ; if zero, then end (string must be null-terminated)
cmp #$20 ; is space? cmp #$20 ; is space?
bne .checkP1 bne .checkP1
@ -134,7 +134,7 @@ printIntro SUBROUTINE
sec sec
sbc #$40 sbc #$40
.print: .print:
sta (introScreenStart),y ; put screen code to screen sta (dstScreenPointer),y ; put screen code to screen
iny ; next char in string iny ; next char in string
jmp .loop jmp .loop
.end: .end:

View File

@ -5,9 +5,9 @@
tileMem DS 2 tileMem DS 2
; Pointer to string ; Pointer to string
printIntroString DS 2 srcStringPointer DS 2
; Pointer to screen position where to print intro string ; Pointer to screen position where to print intro string
introScreenStart DS 2 dstScreenPointer DS 2
; Pointer to level struct ; Pointer to level struct
levelPointer DS 2 levelPointer DS 2