update
This commit is contained in:
parent
7cd1fde406
commit
107311645d
7 changed files with 175 additions and 5 deletions
|
|
@ -5,6 +5,7 @@ add_executable(m68kmake tools/m68kmake.c)
|
||||||
|
|
||||||
file(GLOB_RECURSE SRCS src/**.c)
|
file(GLOB_RECURSE SRCS src/**.c)
|
||||||
list(REMOVE_ITEM SRCS ${CMAKE_CURRENT_SOURCE_DIR}/src/musashi/m68k_in.c ${CMAKE_CURRENT_SOURCE_DIR}/src/musashi/m68kfpu.c)
|
list(REMOVE_ITEM SRCS ${CMAKE_CURRENT_SOURCE_DIR}/src/musashi/m68k_in.c ${CMAKE_CURRENT_SOURCE_DIR}/src/musashi/m68kfpu.c)
|
||||||
|
list(REMOVE_ITEM SRCS ${CMAKE_CURRENT_SOURCE_DIR}/src/tms34010/34010tbl.c ${CMAKE_CURRENT_SOURCE_DIR}/src/tms34010/34010ops.c)
|
||||||
|
|
||||||
find_package(SDL2)
|
find_package(SDL2)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
$000000-$01FFFF ROM
|
$000000-$01FFFF ROM
|
||||||
$100000-$1FFFFF RAM
|
$100000-$1FFFFF RAM
|
||||||
$F00000-$F000FF IO0
|
$F00000-$F000FF IO0 (8254 or compatibles)
|
||||||
$F00100-$F001FF IO1
|
$F00100-$F001FF IO1 (HD44780 compatible LCD)
|
||||||
$F00200-$F002FF IO2
|
$F00200-$F002FF IO2
|
||||||
$F00300-$F003FF IO3
|
$F00300-$F003FF IO3
|
||||||
$F00400-$F004FF IO4
|
$F00400-$F004FF IO4
|
||||||
|
|
|
||||||
BIN
badapple/frames.bin
Normal file
BIN
badapple/frames.bin
Normal file
Binary file not shown.
167
badapple/main.s
Normal file
167
badapple/main.s
Normal file
|
|
@ -0,0 +1,167 @@
|
||||||
|
STACK_AREA equ $1ff000
|
||||||
|
ROM equ $000000
|
||||||
|
RAM equ $100000
|
||||||
|
|
||||||
|
TIMER0 equ $f00000
|
||||||
|
TIMER1 equ $f00002
|
||||||
|
TIMER2 equ $f00004
|
||||||
|
TIMER3 equ $f00006
|
||||||
|
|
||||||
|
LCD equ $f00100
|
||||||
|
LCD_CMD equ $f00100
|
||||||
|
LCD_DATA equ $f00102
|
||||||
|
|
||||||
|
org $000000
|
||||||
|
|
||||||
|
vector_table:
|
||||||
|
dc.l STACK_AREA
|
||||||
|
dc.l init
|
||||||
|
dc.l unhandled_exception ; 2: bus error
|
||||||
|
dc.l unhandled_exception ; 3: address error
|
||||||
|
dc.l unhandled_exception ; 4: illegal instruction
|
||||||
|
dc.l unhandled_exception ; 5: zero divide
|
||||||
|
dc.l unhandled_exception ; 6: chk
|
||||||
|
dc.l unhandled_exception ; 7: trapv
|
||||||
|
dc.l unhandled_exception ; 8: privilege violation
|
||||||
|
dc.l unhandled_exception ; 9: trace
|
||||||
|
dc.l unhandled_exception ; 10: 1010
|
||||||
|
dc.l unhandled_exception ; 11: 1111
|
||||||
|
dc.l unhandled_exception ; 12: -
|
||||||
|
dc.l unhandled_exception ; 13: -
|
||||||
|
dc.l unhandled_exception ; 14: -
|
||||||
|
dc.l unhandled_exception ; 15: uninitialized interrupt
|
||||||
|
dc.l unhandled_exception ; 16: -
|
||||||
|
dc.l unhandled_exception ; 17: -
|
||||||
|
dc.l unhandled_exception ; 18: -
|
||||||
|
dc.l unhandled_exception ; 19: -
|
||||||
|
dc.l unhandled_exception ; 20: -
|
||||||
|
dc.l unhandled_exception ; 21: -
|
||||||
|
dc.l unhandled_exception ; 22: -
|
||||||
|
dc.l unhandled_exception ; 23: -
|
||||||
|
dc.l unhandled_exception ; 24: spurious interrupt
|
||||||
|
dc.l timer_irq ; 25: l1 irq
|
||||||
|
dc.l unhandled_exception ; 26: l2 irq
|
||||||
|
dc.l unhandled_exception ; 27: l3 irq
|
||||||
|
dc.l unhandled_exception ; 28: l4 irq
|
||||||
|
dc.l unhandled_exception ; 29: l5 irq
|
||||||
|
dc.l unhandled_exception ; 30: l6 irq
|
||||||
|
dc.l unhandled_exception ; 31: l7 irq
|
||||||
|
dc.l unhandled_exception ; 32: trap 0
|
||||||
|
dc.l unhandled_exception ; 33: trap 1
|
||||||
|
dc.l unhandled_exception ; 34: trap 2
|
||||||
|
dc.l unhandled_exception ; 35: trap 3
|
||||||
|
dc.l unhandled_exception ; 36: trap 4
|
||||||
|
dc.l unhandled_exception ; 37: trap 5
|
||||||
|
dc.l unhandled_exception ; 38: trap 6
|
||||||
|
dc.l unhandled_exception ; 39: trap 7
|
||||||
|
dc.l unhandled_exception ; 40: trap 8
|
||||||
|
dc.l unhandled_exception ; 41: trap 9
|
||||||
|
dc.l unhandled_exception ; 42: trap 10
|
||||||
|
dc.l unhandled_exception ; 43: trap 11
|
||||||
|
dc.l unhandled_exception ; 44: trap 12
|
||||||
|
dc.l unhandled_exception ; 45: trap 13
|
||||||
|
dc.l unhandled_exception ; 46: trap 14
|
||||||
|
dc.l unhandled_exception ; 47: trap 15
|
||||||
|
|
||||||
|
; d0 is scratch register
|
||||||
|
; d1 is frame counter (decreases)
|
||||||
|
; d2 is timer counter
|
||||||
|
; a0 is scratch register
|
||||||
|
; a1 is frame pointer (increases)
|
||||||
|
; timer is set to 10khz
|
||||||
|
|
||||||
|
init:
|
||||||
|
ori.w #$700, sr
|
||||||
|
move.w #$38, LCD_CMD
|
||||||
|
jsr wait_lcd
|
||||||
|
move.w #$0c, LCD_CMD
|
||||||
|
jsr wait_lcd
|
||||||
|
|
||||||
|
move.w #$80, LCD_CMD
|
||||||
|
jsr wait_lcd
|
||||||
|
move.w #0, LCD_DATA
|
||||||
|
jsr wait_lcd
|
||||||
|
move.w #1, LCD_DATA
|
||||||
|
jsr wait_lcd
|
||||||
|
move.w #2, LCD_DATA
|
||||||
|
jsr wait_lcd
|
||||||
|
|
||||||
|
lea bad_apple, a0
|
||||||
|
jsr print_lcd
|
||||||
|
|
||||||
|
move.w #$c0, LCD_CMD
|
||||||
|
jsr wait_lcd
|
||||||
|
move.w #3, LCD_DATA
|
||||||
|
jsr wait_lcd
|
||||||
|
move.w #4, LCD_DATA
|
||||||
|
jsr wait_lcd
|
||||||
|
move.w #5, LCD_DATA
|
||||||
|
jsr wait_lcd
|
||||||
|
|
||||||
|
move.w #$34, TIMER3 ; timer 0, LSB/MSB, mode 2
|
||||||
|
move.w #$10, TIMER1 ; LSB
|
||||||
|
move.w #$27, TIMER1 ; MSB
|
||||||
|
|
||||||
|
clr.w d3
|
||||||
|
|
||||||
|
jsr init_frames
|
||||||
|
|
||||||
|
eor.w #$700, sr
|
||||||
|
bra.s *
|
||||||
|
|
||||||
|
init_frames:
|
||||||
|
move.w #frames, a1
|
||||||
|
move.w (a1), d1
|
||||||
|
addi.w #2, a1
|
||||||
|
rts
|
||||||
|
|
||||||
|
print_lcd:
|
||||||
|
move.b (a0)+, d0
|
||||||
|
tst.b d0
|
||||||
|
beq.s .done
|
||||||
|
andi.w #$ff, d0
|
||||||
|
move.w d0, LCD_DATA
|
||||||
|
jsr wait_lcd
|
||||||
|
bra.s print_lcd
|
||||||
|
.done:
|
||||||
|
rts
|
||||||
|
|
||||||
|
wait_lcd:
|
||||||
|
move.w LCD_DATA, d0
|
||||||
|
andi.w #80, d0
|
||||||
|
tst.w d0
|
||||||
|
bne.s wait_lcd
|
||||||
|
rts
|
||||||
|
|
||||||
|
timer_irq:
|
||||||
|
addi.w #1, d3
|
||||||
|
cmpi.w #100, d3
|
||||||
|
bne.s .done ; disable this when you're running on emulator
|
||||||
|
clr.w d3
|
||||||
|
.timer:
|
||||||
|
tst.w d1
|
||||||
|
bne.s .no_reset
|
||||||
|
jsr init_frames
|
||||||
|
.no_reset:
|
||||||
|
subi.w #1, d1
|
||||||
|
move.w #$40, LCD_CMD
|
||||||
|
jsr wait_lcd
|
||||||
|
|
||||||
|
move #48, d2
|
||||||
|
.loop:
|
||||||
|
move.b (a1)+, d0
|
||||||
|
move.w d0, LCD_DATA
|
||||||
|
jsr wait_lcd
|
||||||
|
subi.w #1, d2
|
||||||
|
tst.w d2
|
||||||
|
bne.s .loop
|
||||||
|
.done:
|
||||||
|
rte
|
||||||
|
|
||||||
|
unhandled_exception:
|
||||||
|
rte
|
||||||
|
|
||||||
|
bad_apple: dc.b " Bad Apple!!", 0
|
||||||
|
|
||||||
|
frames:
|
||||||
|
incbin "../badapple/frames.bin"
|
||||||
2
rom.c
2
rom.c
|
|
@ -28,6 +28,8 @@ static void lcd_print(const char* str){
|
||||||
#define LCD_FUNCTION_2_LINES (1 << 3)
|
#define LCD_FUNCTION_2_LINES (1 << 3)
|
||||||
|
|
||||||
int main(void){
|
int main(void){
|
||||||
|
int i;
|
||||||
|
|
||||||
lcd_cmd(LCD_FUNCTION | LCD_FUNCTION_8_BITS | LCD_FUNCTION_2_LINES);
|
lcd_cmd(LCD_FUNCTION | LCD_FUNCTION_8_BITS | LCD_FUNCTION_2_LINES);
|
||||||
lcd_cmd(LCD_DISPLAY | LCD_DISPLAY_ON);
|
lcd_cmd(LCD_DISPLAY | LCD_DISPLAY_ON);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,9 @@
|
||||||
|
|
||||||
static unsigned char rom[ROM_SIZE];
|
static unsigned char rom[ROM_SIZE];
|
||||||
static unsigned char ram[RAM_SIZE];
|
static unsigned char ram[RAM_SIZE];
|
||||||
|
|
||||||
static i8254_t i8254;
|
static i8254_t i8254;
|
||||||
|
|
||||||
static VrEmuLcd* lcd;
|
static VrEmuLcd* lcd;
|
||||||
|
|
||||||
#define IS_IO(address, io) ((address) >= 0xf00000 && ((address) & 0xf00) == ((io) << 8))
|
#define IS_IO(address, io) ((address) >= 0xf00000 && ((address) & 0xf00) == ((io) << 8))
|
||||||
|
|
@ -33,7 +35,6 @@ unsigned int m68k_read_memory_8(unsigned int address){
|
||||||
|
|
||||||
return i8254_read(&i8254, (address >> 1) & 3);
|
return i8254_read(&i8254, (address >> 1) & 3);
|
||||||
}else if(IS_IO(address, 1)){
|
}else if(IS_IO(address, 1)){
|
||||||
}else if(IS_IO(address, 2)){
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -63,7 +64,6 @@ void m68k_write_memory_8(unsigned int address, unsigned int value){
|
||||||
}else if(address == 3){
|
}else if(address == 3){
|
||||||
vrEmuLcdWriteByte(lcd, value);
|
vrEmuLcdWriteByte(lcd, value);
|
||||||
}
|
}
|
||||||
}else if(IS_IO(address, 2)){
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -216,7 +216,7 @@
|
||||||
*/
|
*/
|
||||||
#ifndef M68K_INSTRUCTION_HOOK
|
#ifndef M68K_INSTRUCTION_HOOK
|
||||||
#define M68K_INSTRUCTION_HOOK M68K_OPT_OFF
|
#define M68K_INSTRUCTION_HOOK M68K_OPT_OFF
|
||||||
#define M68K_INSTRUCTION_CALLBACK(pc) your_instruction_hook_function(pc)
|
#define M68K_INSTRUCTION_CALLBACK(pc) m68k_instruction(pc)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue