53 lines
1.2 KiB
Odin
53 lines
1.2 KiB
Odin
package main
|
|
|
|
import "core:log"
|
|
import "core:mem"
|
|
|
|
import emu "machine"
|
|
import sim "simulator"
|
|
|
|
DEV :: #config(DEV, false)
|
|
|
|
main :: proc() {
|
|
context.logger = log.create_console_logger()
|
|
defer log.destroy_console_logger(context.logger)
|
|
|
|
when DEV {
|
|
track: mem.Tracking_Allocator
|
|
mem.tracking_allocator_init(&track, context.allocator)
|
|
defer mem.tracking_allocator_destroy(&track)
|
|
|
|
context.allocator = mem.tracking_allocator(&track)
|
|
}
|
|
|
|
// Init the emu 8 "cpu"
|
|
system := emu.init()
|
|
|
|
// @TODO: move this into a gui component
|
|
// load rom, hardcoded for now, will eventually be cli or gui
|
|
err := emu.load_rom(&system, "./test_roms/7-beep.ch8")
|
|
if err != nil {
|
|
panic("failed to load rom!")
|
|
}
|
|
|
|
// Initilize sim, gui etc
|
|
sim.run_simulator(&system)
|
|
|
|
when DEV {
|
|
if len(track.allocation_map) > 0 {
|
|
log.errorf("\nMEMORY LEAKS: %v allocation(s)", len(track.allocation_map))
|
|
for _, entry in track.allocation_map {
|
|
log.errorf(" %v bytes @ %v", entry.size, entry.location)
|
|
}
|
|
}
|
|
|
|
if len(track.bad_free_array) > 0 {
|
|
log.errorf("\nBAD FREES: %v", len(track.bad_free_array))
|
|
|
|
for entry in track.bad_free_array {
|
|
log.errorf(" %v @ %v", entry.memory, entry.location)
|
|
}
|
|
}
|
|
}
|
|
}
|