C64: 2d proof of concept demo

This commit is contained in:
BagoZonde 2015-05-24 11:23:31 +02:00
parent 93efce12eb
commit c32a533cc9
23 changed files with 1200 additions and 0 deletions

22
Platform/C64/README.txt Normal file
View File

@ -0,0 +1,22 @@
Screen memory specification:
Screen is available in Bank #1 ($4000 - $7FFF)
Bitmap is available from $6000 to $7F3F
Video Color RAM is available from $5C00 to $5FF7
Color RAM is available from $D800 to $DBE7 (this range is a default Color RAM range on a C64, cannot be changed)
Sprite pointers are available from $5FF8 to $5FFF
Sprites are available from $5b80 to $5bff (just two sprites)
Features:
Graphic displayed in multicolor bitmap mode
Map size can be freely changed (size of map is saved in header)
64 tiles (each tile contains 4 characters (8x8 pixels each in multicolor mode))
Joystick and keyboard control (WASD keys)
Text can be added to any location
Added some fonts
Tools used:
64tass compiler
GangEd for tiles (data saved separately as videomem, colormem and bitmap) and fonts
SpritePad for sprites

BIN
Platform/C64/data/fonts.GEP Normal file

Binary file not shown.

Binary file not shown.

BIN
Platform/C64/data/tiles.GEP Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

298
Platform/C64/src/2d.asm Normal file
View File

@ -0,0 +1,298 @@
RASTER_TOP_FRAME=170
REGISTER_01=%00110101 ;#$35 (53)
mapPosX = $0a ;and $0b
mapPosY = $0c ;and $0d
mapSizeX = $0e ;and $0f
mapSizeY = $10 ;$and 11
tile = $12
x = $13
y = $14
tileBitmapPointer_LO = $15
tileBitmapPointer_HI = $16
mapBitmapPointer_LO = $17
mapBitmapPointer_HI = $18
mapBitmapPointer2_LO = $19
mapBitmapPointer2_HI = $1a
screenVideoRamPointer_LO = $1b
screenVideoRamPointer_HI = $1c
colorRamPointer_LO = $1d
colorRamPointer_HI = $1e
posX = $1f ;Sprite position X
posY = $20 ;Sprite position Y
mapSizeXAdc = $21 ;and $22
mapPointer_LO = $23
mapPointer_HI = $24
mapPosXMax = $25 ;and $26
mapPosYMax = $27 ;and $28
movementBuffer = $29
textCursor = $2a
calculateDiffer_LO = $2b
calculateDiffer_HI = $2c
locationX = $2d ;and $2e
locationY = $2f ;and $30
textPointerData_LO = $31
textPointerData_HI = $32
mapOffsetPointer_LO = $33
mapOffsetPointer_HI = $34
playerPosition_LO = $35
playerPosition_HI = $36
BANK_START_ADDR=$4000 ;$4000 - $7FFF
SCREEN=$6000 ;Bitmap range: $6000 - $7F3F
SCREEN_VIDEO_RAM=$5C00 ;Screen Video RAM range: $5C00 - $5FFF
SCREEN_COLOR_RAM=$d800 ;Screen Color RAM range: $d800 - $dbe7
;View Port: size of 18 x 18 characters
VIEWPORT_BITMAP_OFFSET=320*3+16
VIEWPORT_SCREEN_OFFSET=40*3+2
;Text Port: size of 16 x 14 characters
TEXTPORT_BITMAP_OFFSET=320*3+16+8*20
TEXTPORT_SCREEN_OFFSET=40*3+2+20
SPRITE_POINTER=SCREEN_VIDEO_RAM+$03F8
SPRITES=$5b80
SPRITE_BASE=(SPRITES - BANK_START_ADDR) / 64 ;calculate where first pointer to sprite bank is located
TILES=$8000 ;Max: 64 tiles, each tile contains 4 quadrates (each quadrates 8x8 pixel size)
TILES_VIDEO_RAM=TILES+64*4*8
TILES_COLOR_RAM=TILES_VIDEO_RAM+64*4
FONTS=$9000
MAP_DATA=$3000
MSX=$A000 ;somewhere around $A000 - $BFFF we will go with music if any (8k free for zaks)
MOVEMENT_DELAY = #6
*=$0801
.word ss,10
.null $9e,^start
ss .word 0
start
sei ;Disable IRQ's
lda #$7f ;Disable CIA IRQ's
sta $dc0d ;Disable timer interrupts
sta $dd0d
lda #REGISTER_01 ;Bank out kernal and basic ($e000-$ffff)
sta $01
lda #<Top_Frame_IRQ ;Install RASTER IRQ
ldx #>Top_Frame_IRQ ;into Hardware
sta $fffe ;Interrupt Vector
stx $ffff
lda #$01
sta $d01a ;Enable RASTER IRQs
lda #RASTER_TOP_FRAME ;IRQ on line RASTER_TOP_FRAME
sta $d012
asl $d019 ;acknowledge video interrupts
bit $dc0d ;acknowledge CIA interrupts
bit $dd0d
lda #0
sta $d020
sta $d021
sta mapPosX
sta mapPosX+1
sta mapPosY
sta mapPosY+1
sta mapSizeXAdc
sta mapSizeXAdc+1
sta movementBuffer
lda #4
sta posX
sta posY
;Get map size
lda MAP_DATA
sta mapSizeX
lda MAP_DATA+1
sta mapSizeX+1
lda MAP_DATA+2
sta mapSizeY
lda MAP_DATA+3
sta mapSizeY+1
;Get map boundaries
lda MAP_DATA ;first for x
sec
sbc #8
sta mapPosXMax
lda MAP_DATA+1
sec
sbc #0
sta mapPosXMax+1
lda MAP_DATA+2 ;then for y
sec
sbc #8
sta mapPosYMax
lda MAP_DATA+3
sec
sbc #0
sta mapPosYMax+1
;Set length of a single row
clc
lda mapSizeX
adc #1
sta mapSizeXAdc
lda mapSizeX+1
adc #0
sta mapSizeXAdc+1
;Clear View Port Screen
lda #0
ldx #160
clearViewPortLoop
.for part=0, part<=49, part=part+1
sta SCREEN + part*160-1,x
.next
dex
beq +
jmp clearViewPortLoop
+
;Clear Text Port Screen
lda #1
ldy #16
-
.for part=0, part<=13, part=part+1
sta SCREEN_VIDEO_RAM + TEXTPORT_SCREEN_OFFSET -1 + part*40,y
sta SCREEN_COLOR_RAM + TEXTPORT_SCREEN_OFFSET -1 + part*40,y
.next
dey
bne -
;Set Screen Bank
lda #$3b
sta $d011 ;Enable Bitmap Mode
lda #$18
sta $d016 ;Enable Multicolor Mode
;Set Bank #1 (from $4000 - $7FFF)
lda #%00000010
sta $dd00
;Set Video Memory for $2C00 offset ($5C00 - $5FFF for bits 4-7 = %0111) and second half of bank for bitmap (bits 1-3 = %100)
lda #%01111000
sta $d018
cli ;Allow IRQ's
;Draw a map
jsr drawMap
;Set sprites
lda #SPRITE_BASE+0
sta SPRITE_POINTER+1
lda #SPRITE_BASE+1
sta SPRITE_POINTER+0
;Enable sprites
lda #1+2
sta $d015
;Set multicolor mode for sprites
lda $d01c
ora #$FF
sta $d01c
;Set sprites colours
lda #8
sta $d027+0
lda #0
sta $d027+1
;Set global multi colours for sprites
lda #3
sta $d025
lda #1
sta $d026
;Set sprites hi byte positions
lda #%00000000
sta $d010
;no graphic overlay on sprites
lda #%00000000
sta $d01b
;Set player on the screen
jsr setPlayer
jsr searchText
;Infinity Loop!
jmp *
;IRQs
.include "includes/irqs/topFrameIRQ.asm"
;Includes
.include "includes/drawMap.asm"
.include "includes/drawTile.asm"
.include "includes/drawPlayer.asm"
.include "includes/searchText.asm"
.include "includes/drawText.asm"
.include "includes/checkTerrain.asm"
;Tables
.include "includes/tables/drawTileTables.asm"
.include "includes/tables/playerPositionTables.asm"
.include "includes/tables/textTables.asm"
*=TILES
.binary "binary/bitmap.PRG",2,64*4*8
*=TILES_VIDEO_RAM
.binary "binary/videomem.PRG",2,64*4
*=TILES_COLOR_RAM
.binary "binary/colormem.PRG",2,64*4
*=FONTS
.binary "binary/fonts.PRG",2,8*26+8*26+8*3
*=MAP_DATA
;.binary "binary/map.bin" ;TODO: As we have no map file yet, let's use fake map for test purposes
.include "binary/map.asm"
*=SPRITES
.binary "binary/sprites.raw",0,64*2 ;only two sprites!
Raster_Indicator
.byte 0
Raster_Indicator_Key_Pressed
.byte 0

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,55 @@
MAP_HEADER
.byte 29, 0 ;Size X of map (LO, HI)
.byte 29, 0 ;Size Y of map (LO, HI)
MAP
.byte 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1
.byte 1, 2, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1
.byte 2, 2, 3, 1, 3, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1
.byte 2, 2, 3, 3, 0, 0, 0, 3, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1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2, 2, 2, 2, 2, 2, 2
.byte 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1
.byte 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1
.byte 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1
.byte 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1
TEXT_HEADER
.byte 2 ;How many text places
TEXT_POINTERS ;(LO/HI)
.byte 4, 0, 4, 0, <text1, >text1
.byte 5, 0, $a, 0, <text2, >text2
TEXTS
text1
.byte 26, 54, 18, 20, 1, 19, 11, 4, 54, 1, 17, 4, 4, 25, 4, 54
.byte 18, 19, 8, 17, 18, 54, 3, 20, 18, 19, 54, 54, 54, 54, 54, 54
.byte 0, 2, 17, 14, 18, 18, 54, 19, 7, 4, 54, 3, 17, 24, 54, 54
.byte 3, 4, 18, 4, 17, 19, 54, 5, 11, 14, 14, 17, 52
.byte $FF
text2
.byte 26, 54, 2, 7, 4, 18, 19, 52
.byte $FF

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,56 @@
checkTerrainLeft
lda playerPosition_LO
sec
sbc #1
sta mapPointer_LO
lda playerPosition_HI
sbc #0
sta mapPointer_HI
jmp checkTerrain
checkTerrainRight
lda playerPosition_LO
clc
adc #1
sta mapPointer_LO
lda playerPosition_HI
adc #0
sta mapPointer_HI
jmp checkTerrain
checkTerrainUp
lda playerPosition_LO
sec
sbc mapSizeXAdc
sta mapPointer_LO
lda playerPosition_HI
sbc mapSizeXAdc+1
sta mapPointer_HI
jmp checkTerrain
checkTerrainDown
lda playerPosition_LO
clc
adc mapSizeXAdc
sta mapPointer_LO
lda playerPosition_HI
adc mapSizeXAdc+1
sta mapPointer_HI
jmp checkTerrain
checkTerrain
ldy #0
lda (mapPointer_LO),y
cmp #1
beq cannotAccess
;Can access
lda #1
rts
cannotAccess
;Cannot access
lda #0
rts

View File

@ -0,0 +1,94 @@
drawMap
lda Raster_Indicator
beq +
lda #2
sta $d020
+
clc
lda #<MAP
adc mapPosX
sta mapPointer_LO
lda #>MAP
adc mapPosX+1
sta mapPointer_HI
;Increment map pointer by a multiplication of row length if map Y position more than 0
lda mapPosY+1
bne setCalculateDiffer
lda mapPosY
beq +
setCalculateDiffer
;Set differ
lda mapPosY
sta calculateDiffer_LO
lda mapPosY+1
sta calculateDiffer_HI
calculateY
;Calculate row on the map (length of rows vary for a particular map so it cannot be pre-calculated in table)
clc
lda mapPointer_LO
adc mapSizeXAdc
sta mapPointer_LO
lda mapPointer_HI
adc mapSizeXAdc+1
sta mapPointer_HI
lda calculateDiffer_LO
sec
sbc #1
sta calculateDiffer_LO
lda calculateDiffer_HI
sbc #0
sta calculateDiffer_HI
;Is it everything?
calculateDiffer
lda calculateDiffer_LO
bne calculateY
lda calculateDiffer_HI
bne calculateY
+
;Remember offset of a map, used for checking terrain type
clc
lda mapPointer_LO
sta mapOffsetPointer_LO
lda mapPointer_HI
sta mapOffsetPointer_HI
.for row=0,row<=8,row=row+1
.for tileN=0,tileN<=8,tileN=tileN+1
ldy #0 + tileN
lda (mapPointer_LO),y
ldx #0 + tileN
ldy #0 + row
jsr drawTile
.next
clc
lda mapPointer_LO
adc mapSizeXAdc
sta mapPointer_LO
lda mapPointer_HI
adc mapSizeXAdc+1
sta mapPointer_HI
.next
lda Raster_Indicator
beq +
lda #0
sta $d020
+
rts

View File

@ -0,0 +1,13 @@
setPlayer
ldy posX
lda playerPosTableX,y
sta $d000
sta $d002
ldy posY
lda playerPosTableY,y
sta $d001
sta $d003
rts

View File

@ -0,0 +1,59 @@
drawText
stx textPointer+1
sty textPointer+2
lda #$FF
sta textCursor
drawTextLoop
inc textCursor
ldy textCursor
textPointer
lda $1234,y
cmp #$FF
beq drawTextDone
sta letter+1
ldy textCursor
lda textPortTable_LO,y
sta textPortPointer+1
lda textPortTable_HI,y
sta textPortPointer+2
lda textPortColorTable_LO,y
sta textPortColor+1
lda textPortColorTable_HI,y
sta textPortColor+2
;Draw a letter
letter
ldy #0
lda fontsTable_LO,y
sta fontPointer+1
lda fontsTable_HI,y
sta fontPointer+2
ldy #8
-
;Switch colour on for this letter
lda #1
textPortColor
sta $1234
fontPointer
lda $1234,y
textPortPointer
sta $1234,y
dey
bne -
jmp drawTextLoop
drawTextDone
rts

View File

@ -0,0 +1,118 @@
;Draw tile
drawTile
sta tile
stx x
sty y
;Get a tile
tay
lda tilesBitmapTable_LO,y
sta tileBitmapPointer_LO
lda tilesBitmapTable_HI,y
sta tileBitmapPointer_HI
clc
lda y
tay
lda multiplyBy9,y ;Multiply y by 9
adc x
tay
lda mapBitmapTable_LO,y
sta mapBitmapPointer_LO
lda mapBitmapTable_HI,y
sta mapBitmapPointer_HI
lda mapBitmapTable2_LO,y
sta mapBitmapPointer2_LO
lda mapBitmapTable2_HI,y
sta mapBitmapPointer2_HI
lda screenVideoRamTable_LO,y
sta screenVideoRamPointer_LO
lda screenVideoRamTable_HI,y
sta screenVideoRamPointer_HI
lda colorRamTable_LO,y
sta colorRamPointer_LO
lda colorRamTable_HI,y
sta colorRamPointer_HI
ldy #16
-
lda (tileBitmapPointer_LO),y
sta (mapBitmapPointer_LO),y
dey
bne -
ldx #16
ldy #32
-
lda (tileBitmapPointer_LO),y
sta (mapBitmapPointer2_LO),y
dey
dex
bne -
;Draw Video RAM
lda tile
asl
asl
tax
ldy #0
lda TILES_VIDEO_RAM,x
sta (screenVideoRamPointer_LO),y
inx
ldy #1
lda TILES_VIDEO_RAM,x
sta (screenVideoRamPointer_LO),y
inx
ldy #40
lda TILES_VIDEO_RAM,x
sta (screenVideoRamPointer_LO),y
inx
ldy #41
lda TILES_VIDEO_RAM,x
sta (screenVideoRamPointer_LO),y
;Draw Color RAM
dex
dex
dex
ldy #0
lda TILES_COLOR_RAM,x
sta (colorRamPointer_LO),y
inx
ldy #1
lda TILES_COLOR_RAM,x
sta (colorRamPointer_LO),y
inx
ldy #40
lda TILES_COLOR_RAM,x
sta (colorRamPointer_LO),y
inx
ldy #41
lda TILES_COLOR_RAM,x
sta (colorRamPointer_LO),y
rts

View File

@ -0,0 +1,281 @@
Top_Frame_IRQ
pha ;store register A in stack
txa
pha ;store register X in stack
tya
pha
inc $d019
lda Raster_Indicator
beq +
lda #2
sta $d020
+
lda movementBuffer
beq calculatePlayerPosition
dec movementBuffer
jmp moveFinished
calculatePlayerPosition ;calculate position of player for further operations like checkTerrain procedure
clc
lda mapOffsetPointer_LO
adc posX
sta playerPosition_LO
lda mapOffsetPointer_HI
adc #0
sta playerPosition_HI
ldy posY
beq +
-
clc
lda playerPosition_LO
adc mapSizeXAdc
sta playerPosition_LO
lda playerPosition_HI
adc mapSizeXAdc+1
sta playerPosition_HI
dey
bne -
+
checkIsUp
lda #%00000001 ;when joystick up
bit $dc00
beq +
lda #%11111101 ;when key "W" hit
sta $dc00
lda $dc01
cmp #%11111101
bne checkIsLeft
+
;Joystick Up
jsr checkTerrainUp
bne +
jmp moveFinished
+
lda MOVEMENT_DELAY
sta movementBuffer
lda mapPosY
cmp #1
bcc ++
lda posY
cmp #5
bcs ++
dec mapPosY
lda mapPosY
cmp #$FF
bne +
dec mapPosY+1
+
jsr drawMap
jsr setPlayer
jsr searchText
jmp moveFinished
+
lda posY
beq +
dec posY
jsr setPlayer
jsr searchText
+
jmp moveFinished
checkIsLeft
lda #%00000100 ;when joystick left
bit $dc00
beq +
lda #%11111101 ;when key "A" hit
sta $dc00
lda $dc01
cmp #%11111011
bne checkIsRight
+
;Joystick Left
jsr checkTerrainLeft
bne +
jmp moveFinished
+
lda MOVEMENT_DELAY
sta movementBuffer
lda mapPosX
cmp #1
bcc ++
lda posX
cmp #5
bcs ++
dec mapPosX
lda mapPosX
cmp #$FF
bne +
dec mapPosX+1
+
jsr drawMap
jsr setPlayer
jsr searchText
jmp moveFinished
+
lda posX
beq +
dec posX
jsr setPlayer
jsr searchText
+
jmp moveFinished
checkIsRight
lda #%00001000 ;when joystick right
bit $dc00
beq +
lda #%11111011 ;when key "D" hit
sta $dc00
lda $dc01
cmp #%11111011
bne checkIsDown
+
;Joystick Right
jsr checkTerrainRight
bne +
jmp moveFinished
+
lda MOVEMENT_DELAY
sta movementBuffer
lda mapPosX+1
cmp mapPosXMax+1
bcc +
lda mapPosX
cmp mapPosXMax
bcs +++
+
lda posX
cmp #4
bcc ++
inc mapPosX
bne +
inc mapPosX+1
+
jsr drawMap
jsr setPlayer
jsr searchText
jmp moveFinished
+
lda posX
cmp #8
beq +
inc posX
jsr setPlayer
jsr searchText
+
jmp moveFinished
checkIsDown
lda #%00000010 ;when joystick down
bit $dc00
beq +
lda #%11111101 ;when key "S" hit
sta $dc00
lda $dc01
cmp #%11011111
bne moveFinished
+
;Joystick Down
jsr checkTerrainDown
bne +
jmp moveFinished
+
lda MOVEMENT_DELAY
sta movementBuffer
lda mapPosY+1
cmp mapPosYMax+1
bcc +
lda mapPosY
cmp mapPosYMax
bcs +++
+
lda posY
cmp #4
bcc ++
inc mapPosY
bne +
inc mapPosY+1
+
jsr drawMap
jsr setPlayer
jsr searchText
jmp moveFinished
+
lda posY
cmp #8
beq +
inc posY
jsr setPlayer
jsr searchText
+
jmp moveFinished
moveFinished
lda #$FB ;when key "R" hit
sta $dc00
lda $dc01
cmp #$FD
bne Free_Raster_Indicator_Key_Pressed
lda Raster_Indicator_Key_Pressed
bne +
lda #1
sta Raster_Indicator_Key_Pressed
;Display raster lines when "R" pressed
lda Raster_Indicator
eor #1
sta Raster_Indicator
lda Raster_Indicator
bne +
lda #0
sta $d020
jmp +
Free_Raster_Indicator_Key_Pressed
lda #0
sta Raster_Indicator_Key_Pressed
+
lda #127 ;Disable keyboard detection
sta $dc00
lda Raster_Indicator
beq +
lda #0
sta $d020
+
pla
tay
pla
tax
pla
rti

View File

@ -0,0 +1,87 @@
searchText
;Clear old text
ldy #15
lda #0
-
.for step=0, step<=15, step=step+1
sta TEXTPORT_SCREEN_OFFSET+SCREEN_COLOR_RAM + step*40 - 1,y
.next
dey
bne -
;Search for new one
clc
lda mapPosX
adc posX
sta locationX
lda mapPosX+1
adc #0
sta locationX+1
clc
lda mapPosY
adc posY
sta locationY
lda mapPosY+1
adc #0
sta locationY+1
;Get how many text places are available on map in general so we can iterate through them
ldx TEXT_HEADER
lda #<TEXT_POINTERS
sta textPointerData_LO
lda #>TEXT_POINTERS
sta textPointerData_HI
-
ldy #0
lda (textPointerData_LO),y
cmp locationX
bne +
ldy #1
lda (textPointerData_LO),y
cmp locationX+1
bne +
ldy #2
lda (textPointerData_LO),y
cmp locationY
bne +
ldy #3
lda (textPointerData_LO),y
cmp locationY+1
bne +
ldy #4
lda (textPointerData_LO),y
tax
ldy #5
lda (textPointerData_LO),y
tay
jsr drawText
rts
+
;Text not match location, search for the next one
clc
lda textPointerData_LO
adc #6
sta textPointerData_LO
lda textPointerData_HI
adc #0
sta textPointerData_HI
dex
bne -
rts

View File

@ -0,0 +1,71 @@
tilesBitmapTable_LO
.for tileN=0, tileN<=63, tileN=tileN+1
.byte <TILES+tileN*32-1
.next
tilesBitmapTable_HI
.for tileN=0, tileN<=63, tileN=tileN+1
.byte >TILES+tileN*32-1
.next
mapBitmapTable_LO
.for tileY=0, tileY<=9*2, tileY=tileY+2
.for tileX=0, tileX<=8, tileX=tileX+1
.byte <VIEWPORT_BITMAP_OFFSET+SCREEN+tileY*320+tileX*16-1-640
.next
.next
mapBitmapTable_HI
.for tileY=0, tileY<=9*2, tileY=tileY+2
.for tileX=0, tileX<=8, tileX=tileX+1
.byte >VIEWPORT_BITMAP_OFFSET+SCREEN+tileY*320+tileX*16-1-640
.next
.next
mapBitmapTable2_LO
.for tileY=0, tileY<=9*2, tileY=tileY+2
.for tileX=0, tileX<=8, tileX=tileX+1
.byte <VIEWPORT_BITMAP_OFFSET+SCREEN+tileY*320+tileX*16-1-320-16
.next
.next
mapBitmapTable2_HI
.for tileY=0, tileY<=9*2, tileY=tileY+2
.for tileX=0, tileX<=8, tileX=tileX+1
.byte >VIEWPORT_BITMAP_OFFSET+SCREEN+tileY*320+tileX*16-1-320-16
.next
.next
screenVideoRamTable_LO
.for tileY=0, tileY<=9*2, tileY=tileY+2
.for tileX=0, tileX<=8, tileX=tileX+1
.byte <VIEWPORT_SCREEN_OFFSET+SCREEN_VIDEO_RAM+tileY*40+tileX*2-80
.next
.next
screenVideoRamTable_HI
.for tileY=0, tileY<=9*2, tileY=tileY+2
.for tileX=0, tileX<=8, tileX=tileX+1
.byte >VIEWPORT_SCREEN_OFFSET+SCREEN_VIDEO_RAM+tileY*40+tileX*2-80
.next
.next
colorRamTable_LO
.for tileY=0, tileY<=9*2, tileY=tileY+2
.for tileX=0, tileX<=8, tileX=tileX+1
.byte <VIEWPORT_SCREEN_OFFSET+SCREEN_COLOR_RAM+tileY*40+tileX*2-80
.next
.next
colorRamTable_HI
.for tileY=0, tileY<=9*2, tileY=tileY+1+1
.for tileX=0, tileX<=8, tileX=tileX+1
.byte >VIEWPORT_SCREEN_OFFSET+SCREEN_COLOR_RAM+tileY*40+tileX*2-80
.next
.next
multiplyBy9
.for mul=1, mul<=9, mul=mul+1
.byte mul*9
.next

View File

@ -0,0 +1,9 @@
playerPosTableX
.for l=0, l<=8, l=l+1
.byte 38+l*16
.next
playerPosTableY
.for l=0, l<=8, l=l+1
.byte 74+l*16
.next

View File

@ -0,0 +1,37 @@
fontsTable_LO
.for l=0, l<=60, l=l+1
.byte <FONTS+l*8-1
.next
fontsTable_HI
.for l=0, l<=60, l=l+1
.byte >FONTS+l*8-1
.next
textPortTable_LO
.for step=0, step<=13, step=step+1
.for l=0, l<=15, l=l+1
.byte <TEXTPORT_BITMAP_OFFSET+SCREEN-1+step*320+l*8
.next
.next
textPortTable_HI
.for step=0, step<=13, step=step+1
.for l=0, l<=15, l=l+1
.byte >TEXTPORT_BITMAP_OFFSET+SCREEN-1+step*320+l*8
.next
.next
textPortColorTable_LO
.for step=0, step<=13, step=step+1
.for l=0, l<=15, l=l+1
.byte <TEXTPORT_SCREEN_OFFSET+SCREEN_COLOR_RAM+step*40+l
.next
.next
textPortColorTable_HI
.for step=0, step<=13, step=step+1
.for l=0, l<=15, l=l+1
.byte >TEXTPORT_SCREEN_OFFSET+SCREEN_COLOR_RAM+step*40+l
.next
.next