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:
lda #<gameoverString
sta printIntroString
sta srcStringPointer
lda #>gameoverString
sta printIntroString + 1
sta srcStringPointer + 1
lda #$00
sta introScreenStart
sta dstScreenPointer
lda #$04
sta introScreenStart + 1
jsr printIntro
sta dstScreenPointer + 1
jsr printString
; Set gameover and outro status
lda #$ff

View File

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

View File

@ -22,25 +22,25 @@ introresetColorShade
; Print website
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
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
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
sta introScreenStart + 1 ; put into msb of dest pointer
jsr printIntro ; print
sta dstScreenPointer + 1 ; put into msb of dest pointer
jsr printString ; print
; Print Copyright
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)
sta printIntroString + 1
sta srcStringPointer + 1
lda #$58
sta introScreenStart
sta dstScreenPointer
lda #$07
sta introScreenStart + 1
jsr printIntro
sta dstScreenPointer + 1
jsr printString
rts

View File

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

View File

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

View File

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