1
0
Disbranĉigi 0

New tiles; figuring out PPU bg attribute table

This commit is contained in:
Jaidyn Ann 2020-10-08 22:58:25 -05:00
parent cf41e032b0
commit b2bf898e72
5 changed files with 16 additions and 13 deletions

View File

@ -1,2 +1,4 @@
test: all
tenes -scale -reset sbp.nes
all: all:
millfork -t nes_small sbp.mfk millfork -t nes_small sbp.mfk

BIN
doc/screen.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

27
sbp.mfk
View File

@ -49,15 +49,22 @@ volatile Gamestate gamestate // the current Gamestate
// CONSTANTS // CONSTANTS
// ============================================================================ // ============================================================================
const array pallete = [ const array pallete = [
$22,$29,$1A,$0F, $22,$36,$17,$0F, $22,$30,$21,$0F, $22,$27,$17,$0F, $22,$29,$1A,$0F,
// construction-blocks
$00,$06,$07,$16,
// construction-bricks
$16,$06,$07,$00,
$22,$27,$17,$0F,
$22,$1C,$15,$14, $22,$1C,$15,$14,
$0F,$18,$28,$0F, // sam $0F,$18,$28,$0F, // sam
$0F,$28,$29,$0F, // enemies $0F,$28,$29,$0F, // enemies
$03,$07,$05,$03 // angry owo $03,$07,$05,$03 // angry owo
] ]
// palette selections for the 16x16 ppu tiles
// %DownRight DownLeft TopRight TopLeft
const array attribute = [ const array attribute = [
%00000101, %00000101, %00000101, %00000101, %00000101, %00000101, %00000101, %00000101, %01010101, %00000101, %00000101, %00000101, %00000101, %00000101, %00000101, %00000101,
%00000101, %00000101, %00000101, %00000101, %00000101, %00000101, %00000101, %00000101, %00000101, %00000101, %00000101, %00000101, %00000101, %00000101, %00000101, %00000101,
%00000101, %00000101, %00000101, %00000101, %00000101, %00000101, %00000101, %00000101 %00000101, %00000101, %00000101, %00000101, %00000101, %00000101, %00000101, %00000101
] ]
@ -164,8 +171,6 @@ void nmi() {
} }
// run at each interrupt request // run at each interrupt request
// ``an irq temporarily stops a program, running an interupt handler instead''
// thanks wikipedia
// do I know when these are called on the nes? absolutely not // do I know when these are called on the nes? absolutely not
// at reset? maybe? // at reset? maybe?
void irq() { void irq() {
@ -380,8 +385,8 @@ macro void load_ingame_attr_table() {
byte i byte i
read_ppu_status() // read PPU status to reset the high/low latch read_ppu_status() // read PPU status to reset the high/low latch
ppu_set_addr(ppu_nametable_0_attr_ram) // point the PPU to nametable 0's attribute table ppu_set_addr(ppu_nametable_0_attr_ram) // point the PPU to nametable 0's attribute table
for i,0,until,$10 { for i,0,until,$37 {
ppu_write_data(attribute[i]) ppu_write_data(attribute[0])
} }
} }
@ -440,9 +445,6 @@ inline void load_sky_background() {
word xx word xx
read_ppu_status() // read PPU status to reset the high/low latch read_ppu_status() // read PPU status to reset the high/low latch
ppu_set_addr(ppu_nametable_ram) // point the PPU to palette ram ppu_set_addr(ppu_nametable_ram) // point the PPU to palette ram
for xx,0,until,$0060 {
ppu_write_data($92) // $00 = sky
}
for xx,0,until,$0300 { for xx,0,until,$0300 {
ppu_write_data($00) // $00 = sky ppu_write_data($00) // $00 = sky
} }
@ -459,19 +461,18 @@ macro void draw_score_text_background() {
macro void draw_boundaries_background() { macro void draw_boundaries_background() {
byte i byte i
//draw top boundary //draw top boundary
read_ppu_status() // read PPU status to reset the high/low latch read_ppu_status() // read PPU status to reset the high/low latch
ppu_set_addr(ppu_nametable_ram+$40) // point the PPU to the top boundary's start ppu_set_addr(ppu_nametable_ram+$40) // point the PPU to the top boundary's start
for i,0,until,$20 { for i,0,until,$20 {
ppu_write_data($81) //write the top boundary tile ppu_write_data($80) //write the top boundary tile
} }
//draw bottom boundary //draw bottom boundary
read_ppu_status() // read PPU status to reset the high/low latch read_ppu_status() // read PPU status to reset the high/low latch
ppu_set_addr(ppu_nametable_ram+$02C0) // point the PPU to the top boundary's start ppu_set_addr(ppu_nametable_ram+$02C0) // point the PPU to the top boundary's start
for i,0,until,$20 { for i,0,until,$80 {
ppu_write_data($80) //write the bottom boundary tile ppu_write_data($83) //write the bottom boundary tile
} }
} }

BIN
sbp.nes

Binary file not shown.

Binary file not shown.