|
|
1.1 root 1: //
2: // nono
1.1.1.3 root 3: // Copyright (C) 2020 nono project
4: // Licensed under nono-license.txt
1.1 root 5: //
6:
1.1.1.8 root 7: //
8: // Human68k .r .x .z console emulator
9: //
10:
1.1 root 11: #pragma once
12:
13: #include "device.h"
1.1.1.9 root 14:
1.1.1.10 root 15: class MainbusDevice;
16: class MainRAMDevice;
1.1.1.9 root 17: class MPU680x0Device;
1.1 root 18:
1.1.1.10 root 19: class Human68kDevice : public Device
1.1.1.3 root 20: {
21: using inherited = Device;
1.1.1.8 root 22:
23: static const uint32 default_load_addr = 0x20000;
24:
25: static const int FilesCount = 256;
26:
1.1 root 27: public:
28: // .X ファイルのヘッダ構造
29: struct XFileHeader {
30: uint8 magic[2]; // +00 識別子 'HU'
31: uint8 unused1;
32: uint8 loadmode; // +03 ロードモード
33: uint32 base_addr; // +04 ベースアドレス
34: uint32 exec_addr; // +08 実行開始アドレス
35: uint32 text_size; // +0c テキストサイズ
36: uint32 data_size; // +10 データサイズ
37: uint32 bss_size; // +14 BSS サイズ
38: uint32 reloc_size; // +18 再配置テーブルサイズ
39: uint32 symbol_size; // +1c シンボルサイズ
40: uint32 scdline_size; // +20 SCD 行番号テーブルサイズ
41: uint32 scdsym_size; // +24 SCD シンボルテーブルサイズ
42: uint32 scdstr_size; // +28 SCD 文字列テーブルサイズ
43: uint32 unused2[4];
44: uint32 module_offset; // +3c モジュールリストの位置
45: } __packed;
46:
47: // .Z ファイルのヘッダ構造
48: struct ZFileHeader {
49: uint16 magic1; // +00 第一識別子 $601a
50: uint32 text_size; // +02 テキストサイズ
51: uint32 data_size; // +06 データサイズ
52: uint32 bss_size; // +0a BSS サイズ
53: uint8 unused[8];
54: uint32 base_addr; // +16 実行開始アドレス
55: uint16 magic2; // +1a 第二識別子 $ffff
56: } __packed;
57:
58: // Human68k File
59: struct File {
60: int fd = -1; // unix fd
1.1.1.3 root 61: std::string filename {};
1.1 root 62: };
63:
1.1.1.10 root 64: Human68kDevice();
65: ~Human68kDevice() override;
1.1 root 66:
1.1.1.3 root 67: bool Init() override;
1.1 root 68:
1.1.1.9 root 69: bool FLineOp();
70:
71: // MSXDOSDevice からも呼ぶ
72: static void RequestExit(int code);
1.1 root 73:
74: private:
75: // Human Emulation API
76: int32 OpenFile(uint32 fileaddr, uint16 atr, int mode);
77: int32 CloseFile(int32 fileno);
78: int32 WriteFile(int32 fileno, uint32 dataaddr, uint32 size);
79: void FputsFile(int32 fileno, uint32 dataaddr);
1.1.1.11! root 80: int GetFileMode(int32 fileno);
1.1 root 81:
1.1.1.9 root 82: void IOCS();
83: void DOS_PRINT(uint32 dataptr);
1.1 root 84:
1.1.1.11! root 85: bool LoadR(const uint8 *memfile, uint size);
! 86: bool LoadX(const uint8 *memfile, uint size);
! 87: bool LoadZ(const uint8 *memfile, uint size);
! 88: bool LoadELF(const uint8 *memfile, uint size);
! 89: bool LoadMem(uint32 addr, const uint8 *src, uint size);
1.1 root 90:
91: bool isext(const char *file, const char *ext);
92:
1.1.1.4 root 93: const char *human68k_file {};
1.1.1.7 root 94: std::string human68k_arg {};
1.1 root 95:
1.1.1.4 root 96: uint32 boot_addr {}; // ローダプログラムアドレス
97: uint32 load_addr {}; // ロードアドレス
98: uint32 load_size {}; // ロードサイズ
1.1 root 99:
1.1.1.4 root 100: uint32 base_addr {}; // ベースアドレス(ファイルの値)
1.1 root 101: // ベースアドレスはload_addr決定で使用される
1.1.1.4 root 102: uint32 exec_addr {}; // 実行開始アドレス
1.1 root 103:
1.1.1.4 root 104: uint32 text_size {}; // テキストセクションサイズ
105: uint32 data_size {}; // データセクションサイズ
106: uint32 bss_size {}; // BSS セクションサイズ(記録用)
1.1 root 107:
108: File Files[FilesCount] {};
1.1.1.8 root 109:
1.1.1.10 root 110: MainbusDevice *mainbus {};
1.1.1.11! root 111: MainRAMDevice *mainram {};
1.1.1.10 root 112: MPU680x0Device *mpu680x0 {};
1.1.1.9 root 113: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.