Xemu [doxygen]  hyppo 0a42be3a057156924bc1b626a687bd6e27349c45 @ Sat 19 Mar 02:15:11 CET 2022
commodore_900.c
Go to the documentation of this file.
1 /* A brave try to emulating Commodore 900 ...
2  * Part of the Xemu project, please visit: https://github.com/lgblgblgb/xemu
3  * Copyright (C)2018 LGB (Gábor Lénárt) <lgblgblgb@gmail.com>
4 
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
18 
19 
20 #include "xemu/emutools.h"
21 #include "z8k1.h"
22 #include "z8010.h"
23 #include "xemu/emutools_config.h"
24 #include "xemu/emutools_files.h"
25 
26 
27 #define BOOT_ROM "#c900-boot-combined.rom"
28 
29 static Uint8 memory[0x10000];
30 
31 
33 {
34  if (seg)
35  FATAL("Currently only segment-0 can be used, given = seg#$%02X", seg);
36  if (ofs >= 0x8000)
37  FATAL("Not handled memory area at offset $%04X", ofs);
38  return memory[ofs];
39 }
40 
42 {
43  ofs &= 0xFFFE;
44  if (seg)
45  FATAL("Currently only segment-0 can be used, given = seg#$%02X", seg);
46  if (ofs >= 0x8000)
47  FATAL("Not handled memory area at offset $%04X", ofs);
48  return (memory[ofs] << 8) | memory[ofs + 1];
49 }
50 
52 {
53  return z8k1_read_word_cb(seg, ofs);
54 }
55 
56 
57 
58 void clear_emu_events ( void )
59 {
60  printf("CLEAR EMU EVENTS!\n");
61 }
62 
63 static char *bootrom_name;
64 
65 
66 int main ( int argc, char **argv )
67 {
68  xemu_pre_init(APP_ORG, TARGET_NAME, "The new-territory-for-me Commodore 900 emulator from LGB");
69  xemucfg_define_str_option("bootrom", BOOT_ROM, "Set BOOT ROM to be loaded", &bootrom_name);
70  if (xemucfg_parse_all(argc, argv))
71  return 1;
72  if (xemu_load_file(bootrom_name, memory, 0x8000, 0x8000, "The boot ROM of Commodore 900 (combined HI+LO)") != 0x8000)
73  return 1;
74  z8k1_init();
75  puts("\nCURRENT GOAL: only disassembly the BOOT ROM and compare it with well known disasm result done by others on boot ROMs\n");
76  z8k1_reset();
77  z8010_init();
78  z8010_reset();
79  for (;;) {
80  if (z8k1_step(0) < 0)
81  break;
82  }
83  return 0;
84 }
85 
xemu_pre_init
void xemu_pre_init(const char *app_organization, const char *app_name, const char *slogan)
Definition: emutools.c:651
xemucfg_define_str_option
void xemucfg_define_str_option(const char *optname, const char *defval, const char *help, char **storage)
z8010_reset
void z8010_reset(void)
Definition: z8010.c:42
emutools.h
z8010_init
void z8010_init(void)
Definition: z8010.c:38
seg
Uint8 seg
Definition: roms.c:41
z8k1_init
void z8k1_init(void)
Definition: z8k1.c:516
z8k1_step
int z8k1_step(int cycles_limit)
Definition: z8k1.c:520
xemucfg_parse_all
int xemucfg_parse_all(int argc, char **argv)
clear_emu_events
void clear_emu_events(void)
Definition: commodore_900.c:58
z8010.h
Uint8
uint8_t Uint8
Definition: fat32.c:51
z8k1_reset
void z8k1_reset(void)
Definition: z8k1.c:487
TARGET_NAME
#define TARGET_NAME
Definition: xemu-target.h:1
emutools_files.h
APP_ORG
#define APP_ORG
Definition: emutools.h:50
z8k1_read_code_cb
Uint16 z8k1_read_code_cb(int seg, Uint16 ofs)
Definition: commodore_900.c:51
emutools_config.h
memory
Uint8 memory[0x100000]
Definition: commodore_65.c:43
xemu_load_file
int xemu_load_file(const char *filename, void *store_to, int min_size, int max_size, const char *cry)
Definition: emutools_files.c:674
BOOT_ROM
#define BOOT_ROM
Definition: commodore_900.c:27
Uint16
uint16_t Uint16
Definition: fat32.c:50
main
int main(int argc, char **argv)
Definition: commodore_900.c:66
z8k1.h
FATAL
#define FATAL(...)
Definition: xep128.h:117
z8k1_read_word_cb
Uint16 z8k1_read_word_cb(int seg, Uint16 ofs)
Definition: commodore_900.c:41
ofs
int ofs
Definition: fat32.c:158
z8k1_read_byte_cb
Uint8 z8k1_read_byte_cb(int seg, Uint16 ofs)
Definition: commodore_900.c:32