init lcd pixels, fix compile warnings

This commit is contained in:
Matthew Laux 2022-06-20 19:52:54 -05:00
parent b0c690c693
commit ec9226e144
4 changed files with 17 additions and 1 deletions

View File

@ -22,7 +22,9 @@ int main(int argc, char *argv[])
if (!rom_load(&rom, argv[1])) {
printf("error loading rom\n");
return 1;
}
}
lcd_new(&lcd);
// this might be too much abstraction but it'll let me
// test the cpu, rom, and dmg independently and use the cpu

View File

@ -265,6 +265,9 @@ static u8 read_reg(struct cpu *cpu, int index)
case 7: return cpu->a;
default: cpu_panic(cpu);
}
// unreachable
return 0;
}
static u8 write_reg(struct cpu *cpu, int index, u8 val)
@ -280,6 +283,9 @@ static u8 write_reg(struct cpu *cpu, int index, u8 val)
case 7: cpu->a = val; break;
default: cpu_panic(cpu);
}
// unreachable
return 0;
}
static void extended_insn(struct cpu *cpu, u8 insn)

View File

@ -1,4 +1,5 @@
#include <stdio.h>
#include <stdlib.h>
#include "types.h"
#include "lcd.h"
@ -13,6 +14,12 @@ static void clear_bit(struct lcd *lcd, u16 addr, u8 bit)
lcd_write(lcd, addr, lcd_read(lcd, addr) & ~(1 << bit));
}
void lcd_new(struct lcd *lcd)
{
// todo < 8 bpp
lcd->pixels = malloc(LCD_WIDTH * LCD_HEIGHT);
}
u8 lcd_is_valid_addr(u16 addr)
{
return addr >= REG_LCD_BASE && addr <= REG_LCD_LAST;

View File

@ -30,6 +30,7 @@ struct lcd {
u8 *pixels;
};
void lcd_new(struct lcd *lcd);
u8 lcd_is_valid_addr(u16 addr);
u8 lcd_read(struct lcd *lcd, u16 addr);
void lcd_write(struct lcd *lcd, u16 addr, u8 value);