handle multi-line comments

This commit is contained in:
2026-05-01 18:27:51 +02:00
parent 92ac475d58
commit c78a2ff7a0
8 changed files with 188 additions and 168 deletions

View File

@@ -4,11 +4,13 @@ pub const game.direction_down = 2
pub const game.direction_left = 3
pub const game.direction_still = 4
/*
; 1_000_000_000 nano second = 0x0000_0000_3B9A_CA00
; pub const game.tick_duration_0 = 0xCA00
; pub const game.tick_duration_1 = 0x3B9A
; pub const game.tick_duration_2 = 0x0000
; pub const game.tick_duration_3 = 0x0000
pub const game.tick_duration_0 = 0xCA00
pub const game.tick_duration_1 = 0x3B9A
pub const game.tick_duration_2 = 0x0000
pub const game.tick_duration_3 = 0x0000
*/
; 0.5 second = 500_000_000 nano second = 0x0000_0000_1DCD_6500
pub const game.tick_duration_0 = 0x6500

View File

@@ -1,21 +1,21 @@
; Screen pixel mode (settings #0)
; 0: ASCII 8
; 1: ASCII 24
; 2: Pixel 8
; 3: Pixel 24
; While in mode #2 (Pixel 8)
; Screen memory offset (settings #1)
; Screen resolutions (settings #2)
; 0. 80x60
; 1. 160x120
; 2. 256x192
; 3. 320x240
; 4. 640x480
; 5. 800x600
; 6. 920x720
; 7. 1024x768
/* Screen pixel mode (settings #0)
0: ASCII 8
1: ASCII 24
2: Pixel 8
3: Pixel 24
While in mode #2 (Pixel 8)
Screen memory offset (settings #1)
Screen resolutions (settings #2)
0. 80x60
1. 160x120
2. 256x192
3. 320x240
4. 640x480
5. 800x600
6. 920x720
7. 1024x768
*/
pub const screen.mode_index = 0
pub const screen.mode_value = 2
pub const screen.offset_index = 1

View File

@@ -1,9 +1,9 @@
;
; Jump table initialisation
;
; r1: sprite id
; r2: pointer address
; r3: pointer value
/* Jump table initialisation
r1: sprite id
r2: pointer address
r3: pointer value
*/
; sprite_empty
add r1, zr, sprites.empty
@@ -54,9 +54,9 @@ add r2, r2, ptr.textures_addresses
add r3, zr, sprite_coin
store_32 [r2], r3
;
; Screen initialization
;
/*
Screen initialization
*/
; r1 = screen parameter value
mov r1, screen.mode_index

View File

@@ -1,17 +1,13 @@
; /* Draw the whole map (fill the screen memory with the values of the sprites based on the map)
/* Draw the whole map (fill the screen memory with the values of the sprites based on the map)
; Inputs:
; Outputs:
; Locals:
; r1: x map coord
; r2: y map coord
; r3: sprite rotation
; r4: sprite id
; r12: rotation (returned by `sprite and rotation`)
; r13: sprite (returned by `get_sprite_id_and_rotation`)
; */
Locals:
r1: x map coord
r2: y map coord
r3: sprite rotation
r4: sprite id
r12: rotation (returned by `sprite and rotation`)
r13: sprite (returned by `get_sprite_id_and_rotation`)
*/
pub drawing.draw_whole_map:
push r1
push r2
@@ -45,19 +41,19 @@ pub drawing.draw_whole_map:
ret
; /* Return the top-left pixel address of the tile at the given map coordinates
/* Return the top-left pixel address of the tile at the given map coordinates
; Inputs:
; r1: map x coord
; r2: map y coord
Inputs:
r1: map x coord
r2: map y coord
; Locals:
; r3: counter
; r4: offset per tile row (screen width * tile height)
Locals:
r3: counter
r4: offset per tile row (screen width * tile height)
; Ouputs:
; r13: the pixel address
; */
Ouputs:
r13: the pixel address
*/
get_tile_address:
push r3
push r4
@@ -104,17 +100,17 @@ get_tile_address:
pop r3
ret
; /* Get address of given sprite id
/* Get address of given sprite id
; Inputs:
; r1: sprite id
Inputs:
r1: sprite id
; Outputs:
; r13: address
Outputs:
r13: address
; Locals:
; r2: pointer address
; */
Locals:
r2: pointer address
*/
get_sprite_address:
push r1
push r2
@@ -132,21 +128,19 @@ get_sprite_address:
pop r1
ret
; /* Draw given sprite on the screen at given map coordinates
/* Draw given sprite on the screen at given map coordinates
; Inputs:
; r1: map x coord
; r2: map y coord
; r3: sprite rotation
; r4: sprite id
Inputs:
r1: map x coord
r2: map y coord
r3: sprite rotation
r4: sprite id
; Outputs:
; Locals:
; r1: screen address
; r2: sprite address
; r13: value returned by call to `get_tile_address` and `get_sprite_address`
; */
Locals:
r1: screen address
r2: sprite address
r13: value returned by call to `get_tile_address` and `get_sprite_address`
*/
pub drawing.draw_sprite_at_map_coord:
push r1
push r2
@@ -172,24 +166,22 @@ pub drawing.draw_sprite_at_map_coord:
pop r1
ret
; /* Draw given sprite (by address) at given screen position (by address) with given rotation
/* Draw given sprite (by address) at given screen position (by address) with given rotation
; Inputs:
; r1: screen address
; r2: sprite address
; r3: rotation
Inputs:
r1: screen address
r2: sprite address
r3: rotation
; Outputs:
; Locals:
; r1: current screen pixel address
; r4: x
; r5: y
; r6: current sprite pixel address
; r7: color
; r8: x increment
; r9: y increment
; */
Locals:
r1: current screen pixel address
r4: x
r5: y
r6: current sprite pixel address
r7: color
r8: x increment
r9: y increment
*/
draw_sprite:
push r1
push r2

View File

@@ -1,12 +1,12 @@
; /* Return the tile address from the given map coordinate
/* Return the tile address from the given map coordinate
; Inputs:
; r1: x map coordinate
; r2: y map coordinate
Inputs:
r1: x map coordinate
r2: y map coordinate
; Outputs:
; r13: tile address
; */
Outputs:
r13: tile address
*/
pub game.get_tile_address_from_map_coord:
push r1
push r2

View File

@@ -1,22 +1,22 @@
; /* Return the sprite id and rotation for the given map coordinates
/* Return the sprite id and rotation for the given map coordinates
; Inputs:
; r1: x map coord
; r2: y map coord
Inputs:
r1: x map coord
r2: y map coord
; Outputs:
; r12: sprite rotation
; r13: sprite id
Outputs:
r12: sprite rotation
r13: sprite id
; Locals:
; r3: tile id
; r4: map offset
; r5: counter
; r6: left tile id
; r7: up tile id
; r8: right tile id
; r9: down tile id
; */
Locals:
r3: tile id
r4: map offset
r5: counter
r6: left tile id
r7: up tile id
r8: right tile id
r9: down tile id
*/
pub sprite_rotation.get_sprite_id_and_rotation:
push r1
push r2

View File

@@ -10,9 +10,9 @@ include init
call drawing.draw_whole_map
;
; State initialization
;
/*
State initialization
*/
; Robot
const robot_initial_x = 1
const robot_initial_y = 1
@@ -51,9 +51,9 @@ mov r3, sprites.rotation_0
mov r4, sprites.ghost
call drawing.draw_sprite_at_map_coord
;
; Time initialization
;
/*
Time initialization
*/
add r1, zr, ptr.tick_duration_low
load_32 r2, [r1]
add r1, zr, ptr.tick_duration_high
@@ -74,13 +74,13 @@ add r1, zr, ptr.next_tick_high
store_32 [r1], r5
game_loop:
;
; Event handling
;
; r1 = keyboard event+key / direction
; r2 = keyboard key / direction address
; r3 = keyboard event
; r4 = jump address
/* Event handling
r1 = keyboard event+key / direction
r2 = keyboard key / direction address
r3 = keyboard event
r4 = jump address
*/
keyboard r1
and r2, r1, keyboard.mask_key
and r3, r1, keyboard.mask_event
@@ -109,7 +109,7 @@ game_loop:
jmp game_loop_event_handling_store_direction
; key_left:
mov r1, game.direction_left
; jmp game_loop_event_handling_end
;jmp game_loop_event_handling_end
game_loop_event_handling_store_direction:
add r2, zr, ptr.state_robot
@@ -118,15 +118,14 @@ game_loop:
game_loop_event_handling_end:
;
; Elapsed time check
;
; r1: address
; r2: now low / delay low
; r3: now high / delay high
; r4: next tick low
; r5: next tick high
;
/* Elapsed time check
r1: address
r2: now low / delay low
r3: now high / delay high
r4: next tick low
r5: next tick high
*/
time_0 r2
time_1 r3
@@ -159,18 +158,18 @@ game_loop:
store_32 [r1], r5
;
; Robot movement
;
; r1 = robot's state address
; r2 = x
; r3 = y
; r4 = direction
; r5 = new x
; r6 = new y
; r7 = new position address
; r8 = new position content
; r9 = jump address
/* Robot movement
r1 = robot's state address
r2 = x
r3 = y
r4 = direction
r5 = new x
r6 = new y
r7 = new position address
r8 = new position content
r9 = jump address
*/
add r1, zr, ptr.state_robot
load_8 r2, [r1]
add r1, r1, 1
@@ -209,9 +208,9 @@ game_loop:
mov r7, r13
pop r2
;
; Collision handling
;
/*
Collision handling
*/
load_8 r8, [r7]
cmp r8, map.tiles.wall
jne game_loop_robot_movement_some
@@ -249,20 +248,20 @@ game_loop:
game_loop_robot_movement_none:
;
; Ghost movement
;
; r1: ghost's state address
; r2: x
; r3: y
; r4: direction
; r5: x increment
; r6: y increment
; r7: new x
; r8: new y
; r9: new position address
; r10: new position content
; r11: jump address
/* Ghost movement
r1: ghost's state address
r2: x
r3: y
r4: direction
r5: x increment
r6: y increment
r7: new x
r8: new y
r9: new position address
r10: new position content
r11: jump address
*/
add r1, zr, ptr.state_ghost
load_8 r2, [r1]
add r1, r1, 1
@@ -331,9 +330,9 @@ game_loop:
mov r4, sprites.ghost
call drawing.draw_sprite_at_map_coord
;
; Check ahead for direction change
;
/*
Check ahead for direction change
*/
add r1, r7, r5
add r2, r8, r6
call game.get_tile_address_from_map_coord