Initial commit, with some added boiler plate.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package main
|
||||
|
||||
import "core:log"
|
||||
import "core:mem"
|
||||
|
||||
import chip "machine"
|
||||
|
||||
// false = release default
|
||||
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 Chip 8 "cpu"
|
||||
system := chip.init()
|
||||
|
||||
// load rom, hardcoded for now, will eventually be cli or gui
|
||||
err := chip.load_rom(&system, "./2-ibm-logo.ch8")
|
||||
if err != nil {
|
||||
panic("failed to load rom!")
|
||||
}
|
||||
|
||||
// start the cycle
|
||||
chip.run(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user