Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set kernel multisprite
- set optimization noinlinedata
- dim tx = temp1
- dim ty = temp2
- dim pptr = temp4
- dim dir = temp5
- dim tdir = temp6
- dim tpb = temp7
- dim sc0 = score
- dim sc1 = score + 1
- dim sc2 = score + 2
- dim dx = a
- dim dy = b
- dim jf = c
- dim sf = d
- dim pno = e
- dim cf = f
- dim lc = g
- const pxb = player0x
- const pyb = player0y
- pfheight = 7
- mk1
- playfield:
- ................
- ................
- ................
- ..............XX
- ..............XX
- ..............XX
- ..............XX
- ................
- ................
- ................
- ................
- end
- player0:
- %00010000
- %01000010
- %00000000
- %10000001
- %00000000
- %01000010
- %00010000
- %10000000
- end
- rem 0 0 upper left
- rem table order left middle = 0
- rem increasing counter clockwise
- rem -16 x offset -10 y offset
- rem 0, 1, 3, 6, 7, 6, 3, 1
- rem 3, 5, 6, 5, 3, 1, 0, 1
- rem $03, $15, $36, $65, $73, $61, $30, $11
- player1:
- %00000000
- %00000000
- %00000000
- %00000000
- %00011111
- %00001110
- %00001110
- %10000100
- end
- rem 0 0 upper left
- rem table order left middle = 0
- rem increasing counter clockwise
- rem -24 x offset -8 y offset
- rem 3, 4, 5, 6, 7, 6, 5, 4
- rem 4, 6, 7, 6, 4, 4, 4, 4
- rem $34, $46, $57, $66, $74, $64, $54, $44
- player2:
- %00011100
- %00000000
- %00110001
- %00000001
- %10000001
- %10000001
- %00000000
- %00011000
- end
- rem 0, 0, 4, 7, 7, 5, 3, 2
- rem 4, 5, 7, 5, 2, 0, 0, 2
- rem $04, $05, $47, $75, $72, $50, $30, $22
- player3:
- %00010000
- %00010000
- %01111000
- %00011111
- %11111000
- %00111110
- %00001000
- %00001000
- end
- rem 0, 2, 4, 6, 7, 4, 3, 1
- rem 4, 5, 7, 5, 3, 2, 0, 2
- rem $04, $25, $47, $65, $73, $42, $30, $12
- player4:
- %00010000
- %00010000
- %00010000
- %01111110
- %00001000
- %00001000
- %00001000
- %00000000
- end
- rem 1, 4, 4, 4, 6, 3, 3, 3
- rem 3, 3, 6, 3, 3, 3, 0, 3
- rem $13, $43, $46, $43, $63, $33, $30, $33
- player5:
- %00000000
- %00010000
- %00011100
- %00110000
- %10000001
- %10010111
- %00010100
- %00011100
- end
- rem 0, 3, 3, 7, 7, 5, 3, 0
- rem 5, 5, 7, 7, 4, 2, 1, 3
- rem $05, $35, $37, $77, $74, $52, $31, $03
- pno = 0 : cf = $FF : jf = $80
- COLUPF = $92
- COLUBK = $9C
- COLUP2 = $56
- COLUP3 = $46
- COLUP4 = $36
- COLUP5 = $26
- player0x = $16 : player1x = $16 : player2x = $16
- player3x = $16 : player4x = $16 : player5x = $16
- player0y = $0C : player1y = $18 : player2y = $24
- player3y = $30 : player4y = $3C : player5y = $48
- main
- temp2 = ((jf ^ $80) & INPT4) & $80 : jf = INPT4
- if temp2 then pno = pno_tbl[pno]
- temp2 = ((SWCHA ^ $FF) & sf)/16 : sf = SWCHA
- temp2 = (sf/16) ^ $0F
- dir = dir_tbl[temp2]
- if !temp2 then no_move
- gosub move_player
- no_move
- temp1 = pxb[pno] : temp2 = pyb[pno]
- gosub update_scr
- COLUP0 = $1C
- COLUP1 = $66
- drawscreen
- goto main
- move_player
- gosub test
- if !cf then move
- rem if not odd-diagonal then done
- rem else check x, y individually
- if !dir{0} then move_done
- dir = (dir - 1) & 7
- gosub test
- if !cf then move
- dir = (dir + 2) & 7
- gosub test
- if cf then move_done
- move
- rem adjust player position according to direction
- pxb[pno] = pxb[pno] + dx_tbl[dir]
- pyb[pno] = pyb[pno] + dy_tbl[dir]
- move_done
- return
- test
- rem dx, dy the are single pixel moves by direction +1 0 -1
- rem pxb[pno], pyb[pno] are the player positions indexed by pno, player number
- rem pxoff[pno] is and offset which is different for player0 (so can't be a constant)
- dx = dx_tbl[dir] + pxb[pno] + pxoff[pno] : dy = dy_tbl[dir] + pyb[pno]+ pyoff[pno]
- rem tpb is the start of player pixel data in the table 8 per player
- rem tdir counts through the pixels,
- rem lc is the loop counter, 5 of 8 pixels checked per direction
- tpb = pno * 8 : tdir = dir : lc = 5
- test_loop
- rem pptr is the index into the player pixel data table
- pptr = tpb + tdir
- rem convert player position to screen coordinates
- rem pixel data packed x in high nibble y in low nibble
- tx = (px_tbl[pptr]/16 + dx)/4 : ty = ((px_tbl[pptr] & $0F)+ dy)/8
- cf = pfread(tx, ty)
- if cf then test_done
- rem increment tdir pixel data pointer by table look up
- rem decrement lc loop counter
- tdir = tdir_tbl[tdir] : lc = lc - 1
- if lc then test_loop
- test_done
- return
- data px_tbl
- $03, $15, $36, $65, $73, $61, $30, $11
- $34, $46, $57, $66, $74, $64, $54, $44
- $04, $05, $47, $75, $72, $50, $30, $22
- $04, $25, $47, $65, $73, $42, $30, $12
- $13, $43, $46, $43, $63, $33, $30, $33
- $05, $35, $37, $77, $74, $52, $31, $03
- end
- data dx_tbl
- 0, 1, 1, 1, 0, -1, -1, -1
- end
- data dy_tbl
- 1, 1, 0, -1, -1, -1, 0, 1
- end
- data dir_tbl
- 0, 0, 4, 0, 6, 7, 5, 0, 2, 1, 3
- end
- data tdir_tbl
- 1, 2, 3, 4, 5, 6, 7, 0
- end
- data pno_tbl
- 1, 2, 3, 4, 5, 0
- end
- data pxoff
- -16, -24, -24, -24, -24, -24
- end
- data pyoff
- -10, -8, -8, -8, -8, -8,
- end
- update_scr
- sc0 = 0 : sc1 = sc1 & 15
- if temp1 >= 100 then sc0 = sc0 + 16 : temp1 = temp1 - 100
- if temp1 >= 100 then sc0 = sc0 + 16 : temp1 = temp1 - 100
- if temp1 >= 50 then sc0 = sc0 + 5 : temp1 = temp1 - 50
- if temp1 >= 30 then sc0 = sc0 + 3 : temp1 = temp1 - 30
- if temp1 >= 20 then sc0 = sc0 + 2 : temp1 = temp1 - 20
- if temp1 >= 10 then sc0 = sc0 + 1 : temp1 = temp1 - 10
- sc1 = (temp1 * 4 * 4) | sc1
- sc1 = sc1 & 240 : sc2 = 0
- if temp2 >= 100 then sc1 = sc1 + 1 : temp2 = temp2 - 100
- if temp2 >= 100 then sc1 = sc1 + 1 : temp2 = temp2 - 100
- if temp2 >= 50 then sc2 = sc2 + 80 : temp2 = temp2 - 50
- if temp2 >= 30 then sc2 = sc2 + 48 : temp2 = temp2 - 30
- if temp2 >= 20 then sc2 = sc2 + 32 : temp2 = temp2 - 20
- if temp2 >= 10 then sc2 = sc2 + 16 : temp2 = temp2 - 10
- sc2 = sc2 | temp2
- return
- asm
- pfread
- clc
- adc #$08
- and #$1F
- cmp #$10
- and #$0F
- tax
- lda bit_masks,x
- bcc skip_PF2_and
- and (PF2pointer),y
- bcs skip_PF1_and
- skip_PF2_and
- and (PF1pointer),y
- skip_PF1_and
- beq skip_ldFF
- lda #$FF
- skip_ldFF
- return
- bit_masks
- .byte $01, $02, $04, $08, $10, $20, $40, $80
- .byte $80, $40, $20, $10, $08, $04, $02, $01
- end
- mk2
- asm
- echo (.mk2 - .mk1)d
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement