aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan J. Martínez <jjm@usebox.net>2022-01-07 19:07:59 +0000
committerJuan J. Martínez <jjm@usebox.net>2022-01-07 19:07:59 +0000
commit0b007b77028aa3ef2056ff915b0a197576b3c4f9 (patch)
treed9e29728697bc3ccf34d322a29a7e9b47e6ea2b0
parentc149e9f96d9f6901656a2dfe4482bb8b45f1f62b (diff)
parentce3c89948e6fc3c7234e8f47e048d74f917e6bf9 (diff)
downloadubox-msx-lib-0b007b77028aa3ef2056ff915b0a197576b3c4f9.tar.gz
ubox-msx-lib-0b007b77028aa3ef2056ff915b0a197576b3c4f9.zip
Merge branch 'master' into 'master'
Replacing VRAM magic numbers with constants See merge request reidrac/ubox-msx-lib!23
-rw-r--r--game/src/game.c4
-rw-r--r--src/spman/spman.c5
-rw-r--r--src/ubox/ubox_fill_screen.z803
-rw-r--r--src/ubox/ubox_get_tile.z803
-rw-r--r--src/ubox/ubox_put_tile.z803
-rw-r--r--src/ubox/ubox_set_sprite_attr.z804
-rw-r--r--src/ubox/ubox_set_sprite_pat16.z804
-rw-r--r--src/ubox/ubox_set_sprite_pat16_flip.z803
-rw-r--r--src/ubox/ubox_set_sprite_pat8.z804
-rw-r--r--src/ubox/ubox_set_sprite_pat8_flip.z803
-rw-r--r--src/ubox/ubox_set_tiles.z807
-rw-r--r--src/ubox/ubox_set_tiles_colors.z807
12 files changed, 33 insertions, 17 deletions
diff --git a/game/src/game.c b/game/src/game.c
index d4942c1..62d5edb 100644
--- a/game/src/game.c
+++ b/game/src/game.c
@@ -17,6 +17,8 @@
#include "player.h"
#include "enemy.h"
+#define BG_TILE_MAP 0x1800
+
void init_map_entities()
{
const uint8_t *m = cur_map;
@@ -91,7 +93,7 @@ void draw_map()
// so we do it in one call by coping our map to the backtround tile map
// addr in the VDP VRAM
ubox_wait_vsync();
- ubox_write_vm((uint8_t *)0x1800, MAP_W * MAP_H, cur_map_data);
+ ubox_write_vm((uint8_t *)BG_TILE_MAP, MAP_W * MAP_H, cur_map_data);
}
void draw_hud()
diff --git a/src/spman/spman.c b/src/spman/spman.c
index 642864e..ba8a939 100644
--- a/src/spman/spman.c
+++ b/src/spman/spman.c
@@ -6,6 +6,7 @@
#define SPMAN_PAT_UNUSED 0xff
#define SPMAN_MAX_SPRITES 32
#define SPMAN_MAX_PATTERNS 64
+#define SPMAN_SPR_ATTRS 0x1b00
uint8_t sp_last_sprite, sp_last_fixed_sprite, sp_idx;
struct sprite_attr sp_fixed[SPMAN_MAX_SPRITES];
@@ -84,7 +85,7 @@ static uint8_t *p;
void spman_update()
{
- p = (uint8_t*) 0x1b00;
+ p = (uint8_t*)SPMAN_SPR_ATTRS;
if (sp_last_sprite)
{
@@ -115,5 +116,5 @@ void spman_update()
void spman_hide_all_sprites()
{
ubox_wait_vsync();
- ubox_write_vm((uint8_t *)0x1b00, 4, (uint8_t *)hide);
+ ubox_write_vm((uint8_t *)SPMAN_SPR_ATTRS, 4, (uint8_t *)hide);
}
diff --git a/src/ubox/ubox_fill_screen.z80 b/src/ubox/ubox_fill_screen.z80
index ed8c58f..e803f76 100644
--- a/src/ubox/ubox_fill_screen.z80
+++ b/src/ubox/ubox_fill_screen.z80
@@ -1,10 +1,11 @@
.globl _ubox_fill_screen
FILVRM = 0x0056
+BG_TILE_MAP = 0x1800
_ubox_fill_screen::
ld a, l
- ld hl, #0x1800
+ ld hl, #BG_TILE_MAP
ld bc, #768
jp FILVRM
diff --git a/src/ubox/ubox_get_tile.z80 b/src/ubox/ubox_get_tile.z80
index 49dcb30..3a6004d 100644
--- a/src/ubox/ubox_get_tile.z80
+++ b/src/ubox/ubox_get_tile.z80
@@ -1,6 +1,7 @@
.globl _ubox_get_tile
RDVRM = 0x004a
+BG_TILE_MAP = 0x1800
_ubox_get_tile::
ld hl, #2
@@ -19,7 +20,7 @@ _ubox_get_tile::
add hl, hl
add hl, bc
- ld bc, #0x1800
+ ld bc, #BG_TILE_MAP
add hl, bc
call RDVRM
diff --git a/src/ubox/ubox_put_tile.z80 b/src/ubox/ubox_put_tile.z80
index 1bdf3ce..24e58b2 100644
--- a/src/ubox/ubox_put_tile.z80
+++ b/src/ubox/ubox_put_tile.z80
@@ -1,6 +1,7 @@
.globl _ubox_put_tile
WRTVRM = 0x004d
+BG_TILE_MAP = 0x1800
_ubox_put_tile::
ld hl, #2
@@ -23,7 +24,7 @@ _ubox_put_tile::
ld b, #0
add hl, bc
- ld bc, #0x1800
+ ld bc, #BG_TILE_MAP
add hl, bc
jp WRTVRM
diff --git a/src/ubox/ubox_set_sprite_attr.z80 b/src/ubox/ubox_set_sprite_attr.z80
index fe573b6..4e5c80e 100644
--- a/src/ubox/ubox_set_sprite_attr.z80
+++ b/src/ubox/ubox_set_sprite_attr.z80
@@ -1,6 +1,8 @@
.globl _ubox_set_sprite_attr
.globl _ubox_write_vm
+SP_ATTRS = 0x1b00
+
_ubox_set_sprite_attr::
ld hl, #2
add hl, sp
@@ -14,7 +16,7 @@ _ubox_set_sprite_attr::
sla l
sla l
ld h, #0
- ld bc, #0x1b00
+ ld bc, #SP_ATTRS
add hl, bc
push de
diff --git a/src/ubox/ubox_set_sprite_pat16.z80 b/src/ubox/ubox_set_sprite_pat16.z80
index 4689267..59d7ccb 100644
--- a/src/ubox/ubox_set_sprite_pat16.z80
+++ b/src/ubox/ubox_set_sprite_pat16.z80
@@ -1,6 +1,8 @@
.globl _ubox_set_sprite_pat16
.globl _ubox_write_vm
+SP_PATTERNS = 0x3800
+
_ubox_set_sprite_pat16::
ld hl, #2
add hl, sp
@@ -17,7 +19,7 @@ _ubox_set_sprite_pat16::
add hl, hl
add hl, hl
add hl, hl
- ld bc, #0x3800
+ ld bc, #SP_PATTERNS
add hl, bc
push de
diff --git a/src/ubox/ubox_set_sprite_pat16_flip.z80 b/src/ubox/ubox_set_sprite_pat16_flip.z80
index bb960f8..5631808 100644
--- a/src/ubox/ubox_set_sprite_pat16_flip.z80
+++ b/src/ubox/ubox_set_sprite_pat16_flip.z80
@@ -1,6 +1,7 @@
.globl _ubox_set_sprite_pat16_flip
WRTVRM = 0x004d
+SP_PATTERNS = 0x3800
_ubox_set_sprite_pat16_flip::
ld hl, #2
@@ -18,7 +19,7 @@ _ubox_set_sprite_pat16_flip::
add hl, hl
add hl, hl
add hl, hl
- ld bc, #0x3800
+ ld bc, #SP_PATTERNS
add hl, bc
push de
diff --git a/src/ubox/ubox_set_sprite_pat8.z80 b/src/ubox/ubox_set_sprite_pat8.z80
index 11b0205..06b484c 100644
--- a/src/ubox/ubox_set_sprite_pat8.z80
+++ b/src/ubox/ubox_set_sprite_pat8.z80
@@ -1,6 +1,8 @@
.globl _ubox_set_sprite_pat8
.globl _ubox_write_vm
+SP_PATTERNS = 0x3800
+
_ubox_set_sprite_pat8::
ld hl, #2
add hl, sp
@@ -15,7 +17,7 @@ _ubox_set_sprite_pat8::
add hl, hl
add hl, hl
add hl, hl
- ld bc, #0x3800
+ ld bc, #SP_PATTERNS
add hl, bc
push de
diff --git a/src/ubox/ubox_set_sprite_pat8_flip.z80 b/src/ubox/ubox_set_sprite_pat8_flip.z80
index a3f8d1d..fdcf9ec 100644
--- a/src/ubox/ubox_set_sprite_pat8_flip.z80
+++ b/src/ubox/ubox_set_sprite_pat8_flip.z80
@@ -1,6 +1,7 @@
.globl _ubox_set_sprite_pat8_flip
WRTVRM = 0x004d
+SP_PATTERNS = 0x3800
_ubox_set_sprite_pat8_flip::
ld hl, #2
@@ -16,7 +17,7 @@ _ubox_set_sprite_pat8_flip::
add hl, hl
add hl, hl
add hl, hl
- ld bc, #0x3800
+ ld bc, #SP_PATTERNS
add hl, bc
ld b, #8
diff --git a/src/ubox/ubox_set_tiles.z80 b/src/ubox/ubox_set_tiles.z80
index fbb2ff9..7e4f42e 100644
--- a/src/ubox/ubox_set_tiles.z80
+++ b/src/ubox/ubox_set_tiles.z80
@@ -1,21 +1,22 @@
.globl _ubox_set_tiles
LDIRVM = 0x005c
+BG_TILES = 0x0
_ubox_set_tiles::
- ld de, #0
+ ld de, #BG_TILES
ld bc, #256 * 8
push hl
call LDIRVM
pop hl
- ld de, #256 * 8
+ ld de, #BG_TILES + #256 * 8
ld bc, #256 * 8
push hl
call LDIRVM
pop hl
- ld de, #256 * 8 * 2
+ ld de, #BG_TILES + #256 * 8 * 2
ld bc, #256 * 8
jp LDIRVM
diff --git a/src/ubox/ubox_set_tiles_colors.z80 b/src/ubox/ubox_set_tiles_colors.z80
index 8ba2609..4c4591b 100644
--- a/src/ubox/ubox_set_tiles_colors.z80
+++ b/src/ubox/ubox_set_tiles_colors.z80
@@ -1,21 +1,22 @@
.globl _ubox_set_tiles_colors
LDIRVM = 0x005c
+BG_COLS = 0x2000
_ubox_set_tiles_colors::
- ld de, #0x2000
+ ld de, #BG_COLS
ld bc, #256 * 8
push hl
call LDIRVM
pop hl
- ld de, #0x2000 + 256 * 8
+ ld de, #BG_COLS + 256 * 8
ld bc, #256 * 8
push hl
call LDIRVM
pop hl
- ld de, #0x2000 + 256 * 8 * 2
+ ld de, #BG_COLS + 256 * 8 * 2
ld bc, #256 * 8
jp LDIRVM