1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-05-28 23:41:32 +00:00
8bitworkshop/presets/c64/common.c

41 lines
739 B
C
Raw Normal View History

2020-02-02 18:17:31 +00:00
#include "common.h"
2022-08-09 14:47:55 +00:00
void raster_wait(byte line) {
2020-02-02 18:17:31 +00:00
while (VIC.rasterline < line) ;
}
2023-11-29 17:15:55 +00:00
void wait_vblank(void) {
raster_wait(250);
}
2022-08-09 14:47:55 +00:00
static byte VIC_BANK_PAGE[4] = {
0xc0, 0x80, 0x40, 0x00
};
2022-08-11 20:27:20 +00:00
char* get_vic_bank_start() {
2022-08-09 14:47:55 +00:00
return (char*)(VIC_BANK_PAGE[CIA2.pra & 3] << 8);
}
2022-08-11 20:27:20 +00:00
char* get_screen_memory() {
return ((VIC.addr & 0xf0) << 6) + get_vic_bank_start();
}
#ifdef __CC65__
2022-08-11 20:27:20 +00:00
char __fastcall__ poll_keyboard() {
asm("jmp $f142");
return __A__;
}
#endif
2022-08-11 20:27:20 +00:00
2023-11-29 17:15:55 +00:00
void set_raster_irq(char scanline) {
// deactivate CIA interrupts (keyboard, etc)
CIA1.icr = 0x7f;
// set raster line for interrupt
VIC.ctrl1 &= 0x7f; // clear raster line bit 8
VIC.rasterline = scanline;
// activate VIC raster interrupts
VIC.imr = 1;
}