;====================================================== ;ASSEMBLE IT ;256 CHAR MAP SCROLLER BY RICHARD BAYLISS ;(C)2018 THE NEW DIMENSION ;HTTP://TND64.UNIKAT.SK ;====================================================== !to "mapscroller.prg",cbm ;SETUP VARIABLES FOR TESTING ;MAPPROW1 = MAP + x * 256 MAPROW1 = MAPDATA ;MAPROWx represents the MAPROW2 = MAPDATA+$100 ;row, that should be read MAPROW3 = MAPDATA+$200 ;and the positioned on to MAPROW4 = MAPDATA+$300 ;the game screen. MAPROW5 = MAPDATA+$400 MAPROW6 = MAPDATA+$500 ;MAPROWx+$yyy = the next MAPROW7 = MAPDATA+$600 ;256 bytes, which is also MAPROW8 = MAPDATA+$700 ;the next map row to be MAPROW9 = MAPDATA+$800 ;drawn on to the next screen. MAPROW10 = MAPDATA+$900 MAPROW11 = MAPDATA+$0A00 MAPROW12 = MAPDATA+$0B00 MAPROW13 = MAPDATA+$0C00 MAPROW14 = MAPDATA+$0D00 MAPROW15 = MAPDATA+$0E00 MAPROW16 = MAPDATA+$0F00 MAPROW17 = MAPDATA+$1000 MAPROW18 = MAPDATA+$1100 MAPROW19 = MAPDATA+$1200 MAPROW20 = MAPDATA+$1300 MAPSCROLLSPEED = 2 ;Set map scroll speed SCRN = $0400 COLR = $D800 *=$0801 !basic 2064 *=$0810 sei lda #$00 sta $d020 sta $d021 lda #$1b sta $d011 lda #$18 sta $d018 lda #$06 sta $d022 lda #$0e sta $d023 ldx #$00 FillScreen lda #$00 sta SCRN,x sta SCRN+$100,x sta SCRN+$200,x sta SCRN+$2e8,x lda #$0b sta COLR,x sta COLR+$100,x sta COLR+$200,x sta COLR+$2e8,x inx bne FillScreen ldx #$00 PutTestMessage lda TestMessage,x sta SCRN+800,x inx cpx #$c8 bne PutTestMessage TestLoop ;Top raster - where the smooth scroller is placed lda #$2e cmp $d012 bne *-3 lda SCROLLX ora #$10 ;Multicolour smooth scroll mode sta $d016 lda #$18 sta $d018 ;Bottom raster - where the static text is placed lda #$d2 cmp $d012 bne *-3 lda #$08 sta $d016 lda #$14 sta $d018 jsr ScrollMap ;Call code for scroller jmp TestLoop ;Start by setting the scroll speed. ScrollExit rts ScrollMap lda SCROLLX sec sbc #MAPSCROLLSPEED and #$07 sta SCROLLX bcs ScrollExit ;Do a hard scroll simply by shifting ;a byte from each character on screen ;then move it to the next character on screen. ;Split this into four different loops. (5 rows per ;loop) ldx #00 ;Grab last value of char - then add it MoveRow1 lda SCRN+1,x ;Grab one screen column higher sta SCRN,x ;pull it to the previous column lda SCRN+41,x sta SCRN+40,x lda SCRN+81,x sta SCRN+80,x lda SCRN+121,x sta SCRN+120,x lda SCRN+161,x sta SCRN+160,x inx cpx #$28 bne MoveRow1 ldx #00 ;Do the same thing for the next set of rows MoveRow2 lda SCRN+201,x sta SCRN+200,x lda SCRN+241,x sta SCRN+240,x lda SCRN+281,x sta SCRN+280,x lda SCRN+321,x sta SCRN+320,x lda SCRN+361,x sta SCRN+360,x inx cpx #$28 bne MoveRow2 ldx #00 ;Once again do the same for the next set of rows MoveRow3 lda SCRN+401,x sta SCRN+400,x lda SCRN+441,x sta SCRN+440,x lda SCRN+481,x sta SCRN+480,x lda SCRN+521,x sta SCRN+520,x lda SCRN+561,x sta SCRN+560,x inx cpx #$28 bne MoveRow3 ldx #00 ;Finally for the last 5 rows MoveRow4 lda SCRN+601,x sta SCRN+600,x lda SCRN+641,x sta SCRN+640,x lda SCRN+681,x sta SCRN+680,x lda SCRN+721,x sta SCRN+720,x lda SCRN+761,x sta SCRN+760,x inx cpx #$28 bne MoveRow4 ;Now place the self-mod stored character on to the ;last byte of each row. mapSM1 lda MAPROW1 sta SCRN+39 mapSM2 lda MAPROW2 sta SCRN+79 mapSM3 lda MAPROW3 sta SCRN+119 mapSM4 lda MAPROW4 sta SCRN+159 mapSM5 lda MAPROW5 sta SCRN+199 mapSM6 lda MAPROW6 sta SCRN+239 mapSM7 lda MAPROW7 sta SCRN+279 mapSM8 lda MAPROW8 sta SCRN+319 mapSM9 lda MAPROW9 sta SCRN+359 mapSM10 lda MAPROW10 sta SCRN+399 mapSM11 lda MAPROW11 sta SCRN+439 mapSM12 lda MAPROW12 sta SCRN+479 mapSM13 lda MAPROW13 sta SCRN+519 mapSM14 lda MAPROW14 sta SCRN+559 mapSM15 lda MAPROW15 sta SCRN+599 mapSM16 lda MAPROW16 sta SCRN+639 mapSM17 lda MAPROW17 sta SCRN+679 mapSM18 lda MAPROW18 sta SCRN+719 mapSM19 lda MAPROW19 sta SCRN+759 mapSM20 lda MAPROW20 sta SCRN+799 ;Now to get a new character fetched from the map, increment ;the lo/byte of the self-modifying addresses in order to ;allow all 256 bytes to update the last character that was ;used after every frame scrolled. inc mapSM1+1 inc mapSM2+1 inc mapSM3+1 inc mapSM4+1 inc mapSM5+1 inc mapSM6+1 inc mapSM7+1 inc mapSM8+1 inc mapSM9+1 inc mapSM10+1 inc mapSM11+1 inc mapSM12+1 inc mapSM13+1 inc mapSM14+1 inc mapSM15+1 inc mapSM16+1 inc mapSM17+1 inc mapSM18+1 inc mapSM19+1 inc mapSM20+1 lda mapSM1+1 beq RESETMAP rts RESETMAP jsr InitMapPosition rts ;Initialise all row positions of the test map ;so that it restarts after the 255th byte read ;in the map. InitMapPosition lda #