Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set smartbranching on
- set romsize 16k
- set kernel_options no_blank_lines
- rem Declare constants
- const true = 1
- const false = 0
- const none = 0
- rem English names for joystick directions
- const vk_nokey = 0
- const vk_left = 1
- const vk_right = 2
- const vk_up = 3
- const vk_down = 4
- const vk_upleft = 5
- const vk_upright = 6
- const vk_downleft = 7
- const vk_downright = 8
- const vk_reset = 9
- const vk_select = 10
- rem My 26 standard colors for NTSC
- const c_brown = $F2
- const c_pink = $3C
- const c_skyblue = $98
- const c_olive = $E4
- const c_lilac = $7A
- const c_aqua = $B8
- const c_orange = $38
- const c_blue = $86
- const c_red = $46
- const c_purple = $64
- const c_lime = $DA
- const c_gold = $2E
- const c_navy = $84
- const c_green = $C6
- const c_maroon = $42
- const c_yellow = $1E
- const c_fuchsia = $58
- const c_cyan = $A6
- const c_white = $0E
- const c_ltgray = $0C
- const c_silver = $0A
- const c_gray = $08
- const c_dkgray = $02
- const c_black = $00
- const c_tan = $FC
- const c_forestgreen = $D2
- rem Object Types
- const o_stairsdown = 1
- const o_stairsup = 2
- const o_warpring = 3
- const style_a = 0
- const style_b = 1
- const style_c = 2
- const style_d = 3
- const style_e = 4
- const style_f = 5
- const style_g = 6
- const style_h = 7
- const style_i = 8
- const style_j = 9
- const style_k = 10
- const style_l = 11
- const style_m = 12
- const style_n = 13
- const style_o = 14
- const pfbase = $A4
- rem English names for system variables
- dim foreground_color=COLUPF
- dim background_color=COLUBK
- rem Declare variables
- rem Global variables (can't be reassigned)
- dim counter = a
- dim boolean_variables = b
- dim key = c
- dim pressed = d
- dim cooldown = e
- dim dungeonlvl = f
- dim worldx = g
- dim worldy = h
- dim rclass = i
- dim roomtype = j
- dim lastkey = k
- dim tempvar = l
- dim gameseed = m
- dim objectcolor = n
- dim object_type = o
- dim item_seed = p
- dim inventory = q
- dim top = r
- dim mid = s
- dim bot = t
- dim dat_ptr = u
- dim dat_len = v
- dim dat_first = w
- dim pf_ptr = x
- macro WRIPFMAC
- asm
- ldx {2}
- ldy {3}
- lda {4}
- clc
- adc {2}
- sta {4}
- WRI_LOOP
- lda {1},y
- sta $A4,x
- iny
- inx
- cpx {4}
- bcc WRI_LOOP
- end
- end
- COLUPF = c_white
- background_color = c_black
- seed_game
- gameseed = gameseed + 1
- if joy0fire then rand = gameseed : item_seed = rand : goto game_create
- drawscreen
- goto seed_game
- game_create
- rem Init game vars
- worldx = 128
- worldy = 128
- dungeonlvl = 1
- rclass = 1
- ballx = 80
- bally = 52
- ballheight = 4
- COLUPF = c_white
- background_color = c_black
- scorecolor = c_red
- CTRLPF = $21
- gosub draw_room
- background_color = c_dkgray
- gosub change_dungeon_color
- game_begin_step
- counter = counter + 1
- if cooldown > 0 then cooldown = cooldown - 1
- game_step
- if collision(ball, playfield) then gosub player_collision_event
- score = 0
- score = score + dungeonlvl
- gosub get_button
- gosub move_player
- if collision(ball, player0) && object_type = o_stairsdown then dungeonlvl = dungeonlvl - 1 : gosub change_dungeon_color : gosub draw_room : ballx = 96 : bally = 40
- if collision(ball, player0) && object_type = o_stairsup then dungeonlvl = dungeonlvl + 1 : gosub change_dungeon_color : gosub draw_room : ballx = 96 : bally = 40
- if collision(ball, player0) && object_type = o_warpring then player0x = 0 : player0y = 0 : inventory = o_warpring : item_seed = rand + item_seed + 23
- if bally > 87 then bally = 12 : worldy = worldy + 1 : gosub draw_room : gosub print_open_up bank4
- if bally < 3 then bally = 78 : worldy = worldy - 1 : gosub draw_room : gosub print_open_down bank4
- if ballx > 141 then ballx = 25 : worldx = worldx + 1 : gosub draw_room : gosub print_open_left bank4
- if ballx < 17 then ballx = 134 : worldx = worldx - 1 : gosub draw_room : gosub print_open_right bank4
- gosub draw_event
- game_end_step
- goto game_begin_step
- draw_event
- COLUP0 = objectcolor
- drawscreen
- return thisbank
- change_dungeon_color
- tempvar{1} = dungeonlvl{1}
- tempvar{2} = 1
- rem Setting bits 2 and 3 to 1 keeps things bright
- tempvar{3} = 1
- tempvar{4} = gameseed{5}
- tempvar{5} = dungeonlvl{0}
- tempvar{6} = gameseed{1}
- tempvar{7} = dungeonlvl{1}
- COLUPF = tempvar
- return thisbank
- move_player
- if key = vk_upleft then ballx = ballx - 1 : bally = bally - 1 : return thisbank
- if key = vk_upright then ballx = ballx + 1 : bally = bally - 1 : return thisbank
- if key = vk_downleft then ballx = ballx - 1 : bally = bally + 1 : return thisbank
- if key = vk_downright then ballx = ballx + 1 : bally = bally + 1 : return thisbank
- if key = vk_left then ballx = ballx - 1 : return thisbank
- if key = vk_right then ballx = ballx + 1 : return thisbank
- if key = vk_up then bally = bally - 1 : return thisbank
- if key = vk_down then bally = bally + 1 : return thisbank
- return thisbank
- player_collision_event
- if lastkey = vk_left then ballx = ballx + 1
- if lastkey = vk_right then ballx = ballx - 1
- if lastkey = vk_up then bally = bally + 1
- if lastkey = vk_down then bally = bally - 1
- if lastkey = vk_upleft then ballx = ballx + 1 : bally = bally + 1
- if lastkey = vk_upright then ballx = ballx - 1 : bally = bally + 1
- if lastkey = vk_downleft then ballx = ballx + 1 : bally = bally - 1
- if lastkey = vk_downright then ballx = ballx - 1 : bally = bally - 1
- return thisbank
- get_button
- lastkey = key
- if cooldown = 0 && joy0fire then pressed = pressed + 1 else pressed = 0
- if joy0up && joy0left then key = vk_upleft : return thisbank
- if joy0up && joy0right then key = vk_upright : return thisbank
- if joy0down && joy0left then key = vk_downleft : return thisbank
- if joy0down && joy0right then key = vk_downright : return thisbank
- if joy0up then key = vk_up : return thisbank
- if joy0down then key = vk_down : return thisbank
- if joy0left then key = vk_left : return thisbank
- if joy0right then key = vk_right : return thisbank
- key = vk_nokey
- return thisbank
- calc_roomtype
- temp1{0} = worldx{0}
- temp1{1} = worldy{6}
- temp1{2} = dungeonlvl{0}
- temp1{3} = worldx{0}
- temp1{4} = worldy{0}
- temp1{5} = dungeonlvl{0}
- temp1{6} = worldx{0}
- temp1{7} = worldy{2}
- temp1 = temp1 + temp1 + temp1
- temp2{0} = worldx{0}
- temp2{1} = worldy{4}
- temp2{2} = dungeonlvl{1}
- temp2{3} = temp1{7}
- temp2{4} = worldy{1}
- temp2{5} = dungeonlvl{1}
- temp2{6} = worldx{1}
- temp2{7} = temp1{1}
- temp3 = temp1 + temp1 + temp2
- temp3{0} = worldx{1}
- temp3{1} = temp2{2}
- temp3{2} = dungeonlvl{5}
- temp3{3} = worldx{2}
- temp3{4} = worldy{2}
- temp3{5} = dungeonlvl{2}
- temp3{6} = temp1{3}
- temp3{7} = worldy{7}
- temp1 = temp1 + temp2 + temp3 + temp1 + gameseed
- if temp1 = 0 then temp1 = 255
- rand = temp1
- roomtype = rand
- tempvar = rand + worldx + worldy
- if counter > 230 then roomtype = rand
- if worldx = 128 && worldy = 128 && dungeonlvl = 1 then roomtype = 1
- rclass = roomtype / 4 / 4 : roomtype = roomtype & $0F
- if rclass = 15 then rclass = style_a
- return thisbank
- draw_room
- gosub calc_roomtype
- gosub print_style bank4
- player0x = 0 : player0y = 0
- if tempvar < 25 && dungeonlvl < 255 then gosub create_stairsup : return thisbank
- if tempvar < 50 && dungeonlvl > 1 then gosub create_stairsdown : return thisbank
- z = tempvar + item_seed
- if z < 51 then gosub create_warpring : return thisbank
- return thisbank
- create_stairsup
- rem player0x = 85
- rem player0y = 38
- objectcolor = c_white
- object_type = o_stairsup
- gosub load_stairsup bank4
- gosub warp_object
- return thisbank
- create_stairsdown
- rem player0x = 69
- rem player0y = 54
- objectcolor = c_black
- object_type = o_stairsdown
- gosub load_stairsdown bank4
- gosub warp_object
- return thisbank
- create_warpring
- rem player0x = 69
- rem player0y = 54
- object_type = o_warpring
- gosub paint_object
- gosub load_warpring bank4
- gosub warp_object
- return thisbank
- paint_object
- objectcolor{1} = object_type{0}
- objectcolor{2} = gameseed{1}
- rem Setting bits 2 and 3 to 1 keeps things bright
- objectcolor{3} = 1
- objectcolor{4} = gameseed{0}
- objectcolor{5} = object_type{1}
- objectcolor{6} = gameseed{0}
- objectcolor{7} = object_type{2}
- return thisbank
- warp_object
- player0x = (rand&63) + 16
- player0y = (rand&63) + 16
- drawscreen
- if collision(player0, playfield) then goto warp_object
- return thisbank
- bank 2
- bank 3
- bank 4
- print_style
- drawscreen
- if roomtype = 1 && rclass = 0 then gosub load_castle : return otherbank
- mid = pat_tbl[rclass]
- bot = ((tempvar ^ mid) & %00000101) ^ mid
- top = bot / 4 & %00000011
- bot = bot & %00000011
- mid = mid / 4 / 4
- mid = (((tempvar ^ mid) & %00000010) ^ mid) & %00000111
- pf_ptr = 0 : dat_ptr = top_tbl[top] : dat_len = 12
- gosub WRI_PF
- pf_ptr = 12 : dat_ptr = mid_tbl[mid] : dat_len = 20
- gosub WRI_PF
- pf_ptr = 32 : dat_ptr = bot_tbl[bot] : dat_len = 12
- gosub WRI_PF
- return otherbank
- WRI_PF
- callmacro WRIPFMAC room_dat pf_ptr dat_ptr dat_len
- return thisbank
- data pat_tbl
- %00000000, %00011000, %01001010, %00010010,
- %01011010, %01010010, %01000010, %01001000,
- %01011000, %00000010, %01010000, %00000010,
- %01000000, %00001010, %00010000
- end
- data top_tbl
- $24, $3C, $18, $30
- end
- data mid_tbl
- $84, $70, $5C, $48, $AC, $98, $D4, $C0
- end
- data bot_tbl
- $24, $0C, $18, $00
- end
- data room_dat
- %11000000, %00000000, %00000000, %11000000
- %11110000, %00000000, %00000000, %11110000
- %11111111, %11111111, %11111111, %11111111
- %11000000, %00000000, %00000000, %11000000
- %11110000, %00000000, %00000000, %11110000
- %11111111, %00011111, %00011111, %11111111
- %11111111, %11111111, %11111111, %11111111
- %11111111, %11111111, %11111111, %11111111
- %11111111, %11111111, %11111111, %11111111
- %11111111, %00011111, %00011111, %11111111
- %11111111, %00011111, %00011111, %11111111
- %11111111, %00011111, %00011111, %11111111
- %11111111, %11111111, %11111111, %11111111
- %11110000, %00000000, %00000000, %11110000
- %11000000, %00000000, %00000000, %11000000
- %11111111, %00011111, %00011111, %11111111
- %11110000, %00000000, %00000000, %11110000
- %11000000, %00000000, %00000000, %11000000
- %10000000, %00000000, %00000000, %10000000
- %10000000, %00000000, %00000000, %10000000
- %10000000, %00000000, %00000000, %10000000
- %10000000, %00000000, %00000000, %10000000
- %10000000, %00000000, %00000000, %10000000
- %10000000, %00000000, %00000000, %10000000
- %00000000, %00000000, %00000000, %00000000
- %00000000, %00000000, %00000000, %00000000
- %00000000, %00000000, %00000000, %00000000
- %10000000, %00000000, %00000000, %10000000
- %11111111, %00011111, %00011111, %11111111
- %11110000, %00000000, %00000000, %11110000
- %11110000, %00000000, %00000000, %11110000
- %11110000, %00000000, %00000000, %11110000
- %11111111, %00011111, %00011111, %11111111
- %11111111, %00011111, %00011111, %11111111
- %00000000, %00000000, %00000000, %00000000
- %00000000, %00000000, %00000000, %00000000
- %00000000, %00000000, %00000000, %00000000
- %11111111, %00011111, %00011111, %11111111
- %11111111, %00011111, %00011111, %11111111
- %00000000, %00000000, %00000000, %11110000
- %00000000, %00000000, %00000000, %11110000
- %00000000, %00000000, %00000000, %11110000
- %11111111, %00011111, %00011111, %11111111
- %11111111, %00011111, %00011111, %11111111
- %11110000, %00000000, %00000000, %00000000
- %11110000, %00000000, %00000000, %00000000
- %11110000, %00000000, %00000000, %00000000
- %11111111, %00011111, %00011111, %11111111
- %10000000, %00000000, %00000000, %10000000
- %00000000, %00000000, %00000000, %10000000
- %00000000, %00000000, %00000000, %10000000
- %00000000, %00000000, %00000000, %10000000
- %10000000, %00000000, %00000000, %10000000
- %10000000, %00000000, %00000000, %10000000
- %10000000, %00000000, %00000000, %00000000
- %10000000, %00000000, %00000000, %00000000
- %10000000, %00000000, %00000000, %00000000
- %10000000, %00000000, %00000000, %10000000
- end
- print_open_left
- pfbase[16]=pfbase[16] & %00000011
- pfbase[20]=pfbase[20] & %00000011
- pfbase[24]=pfbase[24] & %00000011
- return otherbank
- print_open_right
- pfbase[19]=pfbase[19] & %00000011
- pfbase[23]=pfbase[23] & %00000011
- pfbase[27]=pfbase[27] & %00000011
- return otherbank
- print_open_up
- pfbase[1]=pfbase[1] & %00011111 : pfbase[2]=pfbase[2] & %00011111
- pfbase[5]=pfbase[5] & %00011111 : pfbase[6]=pfbase[6] & %00011111
- pfbase[9]=pfbase[9] & %00011111 : pfbase[10]=pfbase[10] & %00011111
- return otherbank
- print_open_down
- pfbase[33]=pfbase[33] & %00011111 : pfbase[34]=pfbase[34] & %00011111
- pfbase[37]=pfbase[37] & %00011111 : pfbase[38]=pfbase[38] & %00011111
- pfbase[41]=pfbase[41] & %00011111 : pfbase[42]=pfbase[42] & %00011111
- return otherbank
- load_stairsup
- player0:
- %11111111
- %10000001
- %11111111
- %00100001
- %00111111
- %00001001
- %00001111
- %00000000
- end
- return otherbank
- load_stairsdown
- player0:
- %11111111
- %10000011
- %11111111
- %10001111
- %11111111
- %10111111
- %11111111
- %11111111
- end
- return otherbank
- load_castle
- pf_ptr = 0 : dat_ptr = 48 : dat_len = 12
- gosub WRI_PF
- pf_ptr = 12 : dat_ptr = 112 : dat_len = 20
- gosub WRI_PF
- pf_ptr = 32 : dat_ptr = 0 : dat_len = 12
- gosub WRI_PF
- gosub print_open_left bank4
- gosub print_open_right bank4
- gosub print_open_up bank4
- gosub print_open_down bank4
- return thisbank
- playfield:
- XXXXXXXXXXXXX......XXXXXXXXXXXXX
- X..............................X
- X..............................X
- X........XX.XX.XX.XX.XX........X
- ..........XXXXXXXXXXXX..........
- .........XXXXX....XXXXX.........
- ................................
- X..............................X
- X..............................X
- X..............................X
- XXXXXXXXXXXXX......XXXXXXXXXXXXX
- end
- return otherbank
- load_warpring
- player0:
- %00111100
- %01000010
- %00111100
- %01011110
- %01101110
- %00111100
- end
- return otherbank
- rem
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement