diff options
author | WlodekM <[email protected]> | 2025-03-31 19:47:54 +0300 |
---|---|---|
committer | WlodekM <[email protected]> | 2025-03-31 19:47:54 +0300 |
commit | cccb99226d3951fd9dfe1c4cf1c43126a1309d51 (patch) | |
tree | 518d3e965558ba313f103cee6161cd2b6aedb3b9 /code/glumbo.a | |
parent | ef4e8c20719822eebd6318a878cc37902c2b85a5 (diff) |
move to pc-thing/
Diffstat (limited to 'code/glumbo.a')
-rw-r--r-- | code/glumbo.a | 271 |
1 files changed, 0 insertions, 271 deletions
diff --git a/code/glumbo.a b/code/glumbo.a deleted file mode 100644 index 72accf6..0000000 --- a/code/glumbo.a +++ /dev/null @@ -1,271 +0,0 @@ -; GLUMBO - the 2d game thing - -.macro store(reg, val, addr) \ - put @reg @val\ - str @reg @addr -.macro storer(reg, val, addr) \ - put @reg @val\ - srr @reg @addr - -jmp start -get_coord: - ld a tmp2 ; Y(0-4) -> a - mov b width ; width (5) -> b - mul ; Y(0-4) * width (5) - - mov a grid_start ; grid start address -> a - swp c b ; (offset from y) -> b - add ; offsetY + gridStart - swp c a ; -> a - ld b tmp1 ; X(0-4) -> b - add ; loc + X - - str c tmp3 ; location -> tmp3 - ret - -start: - .label width 20 - .label height 10 - - .label grid_start 512 - ; temp vars - .label tmp1 0 - .label tmp2 1 - .label tmp3 2 - .label tmp4 3 - .label tmp5 4 - - .label px 16 - .label py 17 - .label inp 256 - store a 2 px - store a 2 py - - store a 0 tmp1 ; x - store a 0 tmp2 ; y - mov a 2 - mov b 1 - sys - grid_loop: - ;get coord - jmr get_coord - ;store tile - ; storer a 46 c - ;main loop stuff - ; place tile - ; get X % (width - 1) to check if on x edge - store a 46 tmp4 - mov a width ; width -> A - mov b 1 ; 1 -> b - sub ; c = width - 1 - swp c b ; -> b - ld a tmp1 ; x -> a - mod ; c = x % (w - 1) - mov a 0 ; - crr c c a ; c = c == 0? - str c tmp5 ; c -> tmp5 - - ; Y % (height - 1 ) - mov a height ; height -> A - mov b 1 ; 1 -> b - sub ; c = height - 1 - swp c b ; -> b - ld a tmp2 ; x -> a - mod ; c = x % (w - 1) - mov a 0 - crr a c a ; a = c == 0? - - ld b tmp5 - or - cmp c 1 - - jz do_the_store ; edge ? continue : jmp do_the_store - store a 35 tmp4 ; store 35 at tmp4 - do_the_store: - ld b tmp3 ; location -> b - ld a tmp4 ; tmp4 (character) -> a - srr a b ; store the tile - ;;;;;;;;;;;;;;;;;;;;;;;;; - mov a width ; width -> a - mov b 1 ; 1 -> b - sub ; c = width - 1 - ld a tmp1 ; X(0-4) -> a - cmr a c ; X(0-4) == width - jnz ifz ; go to ifz if X(0-4) == width (5) - ifnz: ; X is not 0 - ld a tmp1 ; X -> a - mov b 1 ; 1 -> b - add ; X + 1 - str c tmp1 ; X = X + 1 - jmp continue_loop ; continue - ifz: ; X is 0 - store a 0 tmp1 ; set X to 1 - ld a tmp2 ; Y(0-4) -> a - mov b 1 ; 1 -> b - add ; c = Y + 1 - str c tmp2 ; Y = c - jmp continue_loop ; continue - continue_loop: - mov a height - mov b 0 - sub - ld a tmp2 ; get Y (0-4) - cmr a c ; Y == height+1 ? - jz grid_loop ; if not, continue - ; escaped - main_loop: - jmr print - ; get input - mov a 0 - mov b 0 - mov c inp - sys - jmr parse_input - jmp main_loop - -parse_input: - .macro case(addr, val, ln) \ - ld a @addr\ - cmp a @val\ - jnz @ln - .macro break() jmp default - - case inp 119 case_w - case inp 115 case_s - case inp 97 case_a - case inp 100 case_d - - case inp 99 case_c - case inp 3 case_c - break - - case_w: - ld a py - cmp a 0 - jnz default - mov b 1 - sub - str c py - break - - case_s: - ; width-1 - mov a width - mov b 1 - sub - - ld a py - cmr a c - jnz default - mov b 1 - add - str c py - break - - case_a: - ld a px - cmp a 0 - jnz default - mov b 1 - sub - str c px - break - - case_d: - ; width-1 - mov a width - mov b 1 - sub - - ld a px - cmr a c - jnz default - mov b 1 - add - str c px - break - - case_c: - halt - break - - default: - ret - -print: - mov a 1 - mov b 1 - mov c [clear] - sys - store a 0 tmp1 ; x - store a 0 tmp2 ; y - print_loop: - ;get coord - jmr get_coord - ; get tile - ld a tmp3 - ldr b a - str b 128 - store a 0 129 - - ;TODO - make player tile be a @ or something - ld a tmp1 ; x - ld b px ; player x - crr c a b - str c tmp4 - ld a tmp2 ; y - ld b py ; player y - crr b a b - ld a tmp4 - and - cmp c 1 - jz print_normal - store a 64 128 - print_normal: - ; print - mov a 1 - mov b 1 - mov c 128 - sys - ; ld c 128 - ; dbg a - ;loop - mov a width - mov b 1 - sub - ld a tmp1 ; X(0-4) -> a - cmr a c ; X(0-4) == width - jnz p_ifz ; go to ifz if X(0-4) == width - p_ifnz: ; X is not 0 - ld a tmp1 ; X -> a - mov b 1 ; 1 -> b - add ; X + 1 - str c tmp1 ; X = X + 1 - jmp continue_ploop ; continue - p_ifz: ; X is 0 - store a 10 128 - store a 0 129 - mov a 1 - mov b 1 - mov c 128 - sys - store a 0 tmp1 ; set X to 1 - ld a tmp2 ; Y(0-4) -> a - mov b 1 ; 1 -> b - add ; c = Y + 1 - str c tmp2 ; Y = c - jmp continue_ploop ; continue - continue_ploop: - mov a height - mov b 0 - sub - ld a tmp2 ; get Y (0-4) - cmr a c ; Y == width+1 ? - jz print_loop ; if not, continue - ret -clear: -.hex 1b -.str "[2J" -.hex 1b -.str "[0;0H" -.hex 0 \ No newline at end of file |