From b9a09cb3a3d1dd0efbb0d95f301de30cdb104e9e Mon Sep 17 00:00:00 2001 From: Jaidyn Ann Date: Tue, 20 Oct 2020 20:44:34 -0500 Subject: [PATCH] Vertical ranges for tilemapping; map-refactoring --- sbp.mfk | 94 +++++++++++++++++++++++++++++++------------------------- sbp.nes | Bin 40976 -> 40976 bytes 2 files changed, 52 insertions(+), 42 deletions(-) diff --git a/sbp.mfk b/sbp.mfk index fb9e395..75e25f1 100644 --- a/sbp.mfk +++ b/sbp.mfk @@ -1,6 +1,5 @@ /// SUPER BREAD PAN // SUPERPANSKATOL' -// Based on Garydos'es Pong example import nes_joy @@ -17,7 +16,6 @@ struct Sprite { byte x } -// abstraction for 16x16 animated monstrosities // ============================================================================ @@ -468,6 +466,7 @@ inline void draw_score() { // ============================================================================ // ENTITIES // ============================================================================ +// abstraction for 16x16 animated monstrosities struct Entity { Sprite top0, // left side, for the record Sprite bottom0, @@ -641,7 +640,8 @@ void entity_destiny ( pointer.Entity ent ) { // ============================================================================ // load a map onto the ppu void init_map ( pointer.word locations, pointer location_tiles, - pointer.word ranges, pointer range_tiles, + pointer.word horiz_ranges, pointer horiz_tiles, + pointer.word vert_ranges, pointer vert_tiles, pointer pallete, pointer attrs ) { byte i word j @@ -653,21 +653,45 @@ void init_map ( pointer.word locations, pointer location_tiles, load_attr_table( attrs ) blank_bg() - read_ppu_status() + + init_map_horiz_ranges( horiz_ranges, horiz_tiles ) + init_map_vert_ranges ( vert_ranges, vert_tiles ) + init_map_locations( locations, location_tiles ) + +} + +// init_map helpers +// ----------------- +macro void init_map_horiz_ranges ( pointer.word horiz_ranges, pointer horiz_tiles ) { + const byte horiz_inc = $1 + ppu_load_range( horiz_ranges, horiz_tiles, horiz_inc ) +} + +macro void init_map_vert_ranges ( pointer.word vert_ranges, pointer vert_tiles ) { + const byte vert_inc = $20 + ppu_load_range( vert_ranges, vert_tiles, vert_inc ) +} + +macro void init_map_locations ( pointer.word locations, pointer location_tiles ) { i = 0 while ( locations[i] != nullchar ) { ppu_set_addr(ppu_nametable_ram + locations[i]) ppu_write_data(location_tiles[i]) i += 1 } +} +macro void ppu_load_range ( pointer.word ranges, pointer tiles, byte increment ) { i = 0 + last_range = 0 while ( ranges[i] != nullchar ) { if last_range != 0 { - ppu_set_addr(ppu_nametable_ram + ranges[i-1]) - for j,ranges[i-1],to,ranges[i] { - ppu_write_data(range_tiles[i/2]) + j = ranges[i-1] + while ( j <= ranges[i] ) { + ppu_set_addr( ppu_nametable_ram + j ) + ppu_write_data(tiles[i/2]) // bug when i==1? + j += increment } last_range = 0 } else { @@ -677,48 +701,34 @@ void init_map ( pointer.word locations, pointer location_tiles, } } -void init_map1_c () { - init_map( pointer.word( MAP1_C_LOCATIONS ), MAP1_C_LOCATION_TILES, - pointer.word( MAP1_C_RANGES ), MAP1_C_RANGE_TILES, - MAP1_C_PALLETE, MAP1_C_ATTRS ) -} // ------------------------------------- // MAP DATA // ------------------------------------- // map1: construction site -// not the most efficient way to store this data. -// _RANGES is for horizontal lines, left to right. -// _LOCATIONS should only be used for one-off, random blocks. right now it's used -// for manually typing in vertical lines, gross. +void init_map1_c () { + init_map( pointer.word( MAP1_C_LOCATIONS ), MAP1_C_LOCATION_TILES, + pointer.word( MAP1_C_HORIZ ), MAP1_C_HORIZ_TILES, + pointer.word( MAP1_C_VERT ), MAP1_C_VERT_TILES, + MAP1_C_PALLETE, MAP1_C_ATTRS ) +} + const array(word) MAP1_C_LOCATIONS = [ - // border pillars (far left and right) - $22,$3D, $42,$5D, $62,$7D, $82,$9D, - $A2,$BD, $C2,$DD, $E2,$FD, $102,$11D, - $122,$13D, $142,$15D, $162,$17D, $182,$19D, - $1A2,$1BD, $1C2,$1DD, $1E2,$1FD, $202,$21D, - $222,$23D, $242,$25D, $262,$27D, $282,$29D, - $2A2,$2BD, $2C2,$2DD, $2E2,$2FD, - // lift up top platform - $A,$2A,$4A,$6A,$8A,$AA,$CA,$EA, - $15,$35,$55,$75,$95,$B5,$D5,$F5, - // lift up bottom platform - $26A,$28A,$2AA,$2CA,$2EA,$30A, - $275,$295,$2B5,$2D5,$2F5,$315, + $22,$3D, $1A2,$1BD, $2E2,$2FD, // bolted parts of arena border + $EA,$F5, $26A,$275, // holding up bottom/top platforms w connecting metal nullchar ] -const array(byte) MAP1_C_LOCATION_TILES = [ - $81,$81, $82,$82, $82,$82, $82,$82, - $82,$82, $82,$82, $82,$82, $82,$82, - $82,$82, $82,$82, $82,$82, $82,$82, - $81,$81, $82,$82, $82,$82, $82,$82, - $82,$82, $82,$82, $82,$82, $82,$82, - $82,$82, $82,$82, $81,$81, - $85,$85,$85,$85,$85,$85,$85,$89, - $86,$86,$86,$86,$86,$86,$86,$8A, - $87,$85,$85,$85,$85,$85, - $88,$86,$86,$86,$86,$86 ] +const array(byte) MAP1_C_LOCATION_TILES = [ + $81,$81, $81,$81, $81,$81, + $89,$8A, $87,$88 ] -const array(word) MAP1_C_RANGES = [ +const array(word) MAP1_C_VERT = [ + $22,$2E2, $3D,$2FD, // arena border (far left & right) + $4A,$EA, $55,$F5, // lift up top platform + $26A,$30A, $275,$315, // hold up bottom platform + nullchar ] +const array(byte) MAP1_C_VERT_TILES = [ $82,$82, $85,$86, $85,$86 ] + +const array(word) MAP1_C_HORIZ = [ $340,$3A0, // sandstone subterrain $300,$308, $317,$31F, // brick floor (top) $320,$32E, $331,$33F, // brick floor (second) @@ -727,7 +737,7 @@ const array(word) MAP1_C_RANGES = [ $1A3,$1A8, $1B7,$1BC, // middle platforms $249,$256, // bottom platform nullchar ] -const array(byte) MAP1_C_RANGE_TILES = [ $84, $83,$83,$83,$83, $80,$80, $80, $80,$80, $80 ] +const array(byte) MAP1_C_HORIZ_TILES = [ $84, $83,$83, $83,$83, $80,$80, $80, $80,$80, $80 ] const array(byte) MAP1_C_PALLETE = [ $21, // bg color $29,$1A,$0F, $00, diff --git a/sbp.nes b/sbp.nes index 42c4179d386c1bc7a1f1e16139aa2a00a0ff244d..701af146cb9d5646425340a04fea99cf87f98e21 100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