reduce canvas to 1/4 size
This commit is contained in:
parent
df69692587
commit
5e587957b4
|
@ -32,5 +32,93 @@ bool ppu_shows_sprites();
|
|||
bool ppu_in_vblank();
|
||||
void ppu_set_in_vblank(bool yesno);
|
||||
|
||||
// PPU Memory and State
|
||||
typedef struct {
|
||||
byte PPUCTRL; // $2000 write only
|
||||
byte PPUMASK; // $2001 write only
|
||||
byte PPUSTATUS; // $2002 read only
|
||||
byte OAMADDR; // $2003 write only
|
||||
byte OAMDATA; // $2004
|
||||
word PPUSCROLL;
|
||||
byte PPUSCROLL_X, PPUSCROLL_Y; // $2005 write only x2
|
||||
word PPUADDR; // $2006 write only x2
|
||||
word PPUDATA; // $2007
|
||||
|
||||
bool scroll_received_x;
|
||||
bool addr_received_high_byte;
|
||||
bool ready;
|
||||
|
||||
int mirroring, mirroring_xor;
|
||||
|
||||
int x, scanline;
|
||||
} PPU_STATE;
|
||||
|
||||
extern PPU_STATE ppu;
|
||||
extern byte ppu_latch;
|
||||
extern bool ppu_sprite_hit_occured;
|
||||
extern byte ppu_screen_background[264][248];
|
||||
|
||||
word ppu_get_real_ram_address(word address);
|
||||
|
||||
|
||||
// Screen State and Rendering
|
||||
|
||||
static inline byte ppu_l_h_addition(int h, int l, int x) {
|
||||
return (((h >> (7 - x)) & 1) << 1) | ((l >> (7 - x)) & 1);
|
||||
}
|
||||
static inline byte ppu_l_h_addition_flip(int l, int h, int x) {
|
||||
return (((h >> x) & 1) << 1) | ((l >> x) & 1);
|
||||
}
|
||||
|
||||
|
||||
// Draws current screen pixels in ppu_background_pixels & ppu_sprite_pixels and clears them
|
||||
void ppu_render_screen();
|
||||
void ppu_set_background_color(byte color);
|
||||
|
||||
|
||||
|
||||
// PPUCTRL Functions
|
||||
|
||||
word ppu_base_nametable_address();
|
||||
byte ppu_vram_address_increment();
|
||||
word ppu_sprite_pattern_table_address();
|
||||
word ppu_background_pattern_table_address();
|
||||
byte ppu_sprite_width();
|
||||
byte ppu_sprite_height();
|
||||
bool ppu_generates_nmi();
|
||||
|
||||
|
||||
|
||||
// PPUMASK Functions
|
||||
|
||||
bool ppu_renders_grayscale();
|
||||
bool ppu_shows_background_in_leftmost_8px();
|
||||
bool ppu_shows_sprites_in_leftmost_8px();
|
||||
bool ppu_intensifies_reds();
|
||||
bool ppu_intensifies_greens();
|
||||
bool ppu_intensifies_blues();
|
||||
void ppu_set_renders_grayscale(bool yesno);
|
||||
void ppu_set_shows_background_in_leftmost_8px(bool yesno);
|
||||
void ppu_set_shows_sprites_in_leftmost_8px(bool yesno);
|
||||
void ppu_set_shows_background(bool yesno);
|
||||
void ppu_set_shows_sprites(bool yesno);
|
||||
void ppu_set_intensifies_reds(bool yesno);
|
||||
void ppu_set_intensifies_greens(bool yesno);
|
||||
void ppu_set_intensifies_blues(bool yesno);
|
||||
|
||||
|
||||
|
||||
// PPUSTATUS Functions
|
||||
|
||||
bool ppu_sprite_overflow();
|
||||
bool ppu_sprite_0_hit();
|
||||
bool ppu_in_vblank();
|
||||
|
||||
void ppu_set_sprite_overflow(bool yesno);
|
||||
void ppu_set_sprite_0_hit(bool yesno);
|
||||
void ppu_set_in_vblank(bool yesno);
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include "cpu.h"
|
||||
#include "cpu-internal.h"
|
||||
#include "memory.h"
|
||||
|
||||
// CPU Addressing Modes
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include "hal.h"
|
||||
#include "nes.h"
|
||||
|
||||
_Pixel canvas[W][H];
|
||||
|
||||
typedef struct {
|
||||
char signature[4];
|
||||
|
@ -115,10 +114,11 @@ void fce_run()
|
|||
|
||||
// Rendering
|
||||
|
||||
byte canvas[W][H];
|
||||
|
||||
void fce_update_screen()
|
||||
{
|
||||
int idx = ppu_ram_read(0x3F00);
|
||||
_Pixel bgc = palette[idx];
|
||||
|
||||
int w = _screen.width;
|
||||
int h = _screen.height;
|
||||
|
@ -126,13 +126,14 @@ void fce_update_screen()
|
|||
int pad = (w - h) / 2;
|
||||
for (int x = pad; x < w - pad; x ++) {
|
||||
for (int y = 0; y < h; y ++) {
|
||||
_draw_p(x, y, canvas[(x - pad) * W / h][y * H / h]);
|
||||
_draw_p(x, y, palette[canvas[(x - pad) * W / h][y * H / h]]);
|
||||
}
|
||||
}
|
||||
|
||||
_draw_sync();
|
||||
|
||||
for (int i = 0; i < W; i ++)
|
||||
for (int j = 0; j < H; j ++)
|
||||
canvas[i][j] = bgc;
|
||||
canvas[i][j] = idx;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,20 +1,25 @@
|
|||
#include "ppu.h"
|
||||
#include "ppu-internal.h"
|
||||
#include "cpu.h"
|
||||
#include "fce.h"
|
||||
#include "memory.h"
|
||||
#include "hal.h"
|
||||
|
||||
static const word ppu_base_nametable_addresses[4] = { 0x2000, 0x2400, 0x2800, 0x2C00 };
|
||||
|
||||
byte ppu_sprite_palette[4][4];
|
||||
bool ppu_2007_first_read;
|
||||
byte ppu_addr_latch;
|
||||
PPU_STATE ppu;
|
||||
byte ppu_latch;
|
||||
bool ppu_sprite_hit_occured = false;
|
||||
byte ppu_screen_background[264][248];
|
||||
|
||||
|
||||
extern _Pixel canvas[W][H];
|
||||
extern byte canvas[W][H];
|
||||
|
||||
void draw(int x, int y, int idx) {
|
||||
if (x >= 0 && x < W && y >= 0 && y < H) {
|
||||
canvas[x][y] = palette[idx];
|
||||
if (x >= 0 && y >= 0 && x < W && y < H) {
|
||||
// _draw_p(x, y, palette[idx]);
|
||||
canvas[x][y] = idx;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue