mirror of https://github.com/mlaux/gb6.git
init lcd pixels, fix compile warnings
This commit is contained in:
parent
b0c690c693
commit
ec9226e144
|
@ -22,7 +22,9 @@ int main(int argc, char *argv[])
|
||||||
if (!rom_load(&rom, argv[1])) {
|
if (!rom_load(&rom, argv[1])) {
|
||||||
printf("error loading rom\n");
|
printf("error loading rom\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lcd_new(&lcd);
|
||||||
|
|
||||||
// this might be too much abstraction but it'll let me
|
// this might be too much abstraction but it'll let me
|
||||||
// test the cpu, rom, and dmg independently and use the cpu
|
// test the cpu, rom, and dmg independently and use the cpu
|
||||||
|
|
|
@ -265,6 +265,9 @@ static u8 read_reg(struct cpu *cpu, int index)
|
||||||
case 7: return cpu->a;
|
case 7: return cpu->a;
|
||||||
default: cpu_panic(cpu);
|
default: cpu_panic(cpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// unreachable
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static u8 write_reg(struct cpu *cpu, int index, u8 val)
|
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;
|
case 7: cpu->a = val; break;
|
||||||
default: cpu_panic(cpu);
|
default: cpu_panic(cpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// unreachable
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void extended_insn(struct cpu *cpu, u8 insn)
|
static void extended_insn(struct cpu *cpu, u8 insn)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "lcd.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));
|
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)
|
u8 lcd_is_valid_addr(u16 addr)
|
||||||
{
|
{
|
||||||
return addr >= REG_LCD_BASE && addr <= REG_LCD_LAST;
|
return addr >= REG_LCD_BASE && addr <= REG_LCD_LAST;
|
||||||
|
|
|
@ -30,6 +30,7 @@ struct lcd {
|
||||||
u8 *pixels;
|
u8 *pixels;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void lcd_new(struct lcd *lcd);
|
||||||
u8 lcd_is_valid_addr(u16 addr);
|
u8 lcd_is_valid_addr(u16 addr);
|
||||||
u8 lcd_read(struct lcd *lcd, u16 addr);
|
u8 lcd_read(struct lcd *lcd, u16 addr);
|
||||||
void lcd_write(struct lcd *lcd, u16 addr, u8 value);
|
void lcd_write(struct lcd *lcd, u16 addr, u8 value);
|
||||||
|
|
Loading…
Reference in New Issue