I have started learning a little assembler of the past few months so that I can enhance my BASIC programming. As an exercise, I am trying to recreate the sort of scroll employed in Konami's Road Fighter. The task is therefore to create a routine which scrolls the lefthand 22 characters of 24 lines of a 30 character width Screen 1.
Being a total ASM noob, I have managed to produce the following, which works:
.BASIC ROWLEN EQU 22 VRMADR EQU 6144 ORG $D000 ; Start Address JP SCROLL ; &HD000 SCROLL: LD HL,VRMADR+705 ; Set VRAM address LD [TARGET],HL LD C,23 ; Set Counter (screen rows) LOOPS: PUSH BC ; Preserve counter LD HL,[TARGET] ; Calc Address LD DE,BUFFER LD BC,ROWLEN CALL $0059 LD HL,[TARGET] ; Copy RAM block back to VRAM 1 row lower LD DE,32 ADD HL,DE LD DE,BUFFER EX DE,HL LD BC,ROWLEN CALL $005C LD HL,[TARGET] ; Move address up 1 row LD DE,-32 ADD HL,DE LD [TARGET],HL POP BC ; Restore counter and check for end of loop DEC C JR NZ,LOOPS RET BUFFER: DS 32 ; Reserve [V]RAM Space TARGET: DS 4 ; Current MOVEBL Address
I call it from BASIC like this:
100 CLEAR200,&HD000 110 SCREEN1:WIDTH30:KEYOFF 115 CLS:LOCATE22,0:PRINT"HISCORE" 120 BLOAD"SCROLL.BIN":DEFUSR=&HD000 130 K=31 140 A=USR(0):LOCATE0,0:PRINTSTRING$(22,K):K=K+1:IFK=255THENK=31 150 GOTO140
Is there is a better/faster way of doing this?
Login or 등록 to post comments
