From 8d4cade6f08d98f3ecffb4d5f8258509e273000f Mon Sep 17 00:00:00 2001 From: David Schmenk Date: Sun, 21 Apr 2019 06:53:32 -0700 Subject: [PATCH] Initial check-in --- Makefile | 121 ++ icons/ApPalm_13x9_256.bmp | Bin 0 -> 1222 bytes icons/ApPalm_15x9_16grey.bmp | Bin 0 -> 190 bytes icons/ApPalm_15x9_256.bmp | Bin 0 -> 1222 bytes icons/ApPalm_15x9_4grey.bmp | Bin 0 -> 190 bytes icons/ApPalm_15x9_B&W.bmp | Bin 0 -> 98 bytes icons/ApPalm_32x22_16grey.bmp | Bin 0 -> 470 bytes icons/ApPalm_32x22_256.bmp | Bin 0 -> 1782 bytes icons/ApPalm_32x22_4grey.bmp | Bin 0 -> 470 bytes icons/ApPalm_32x22_B&W.bmp | Bin 0 -> 150 bytes icons/ApPalm_32x22_original.bmp | Bin 0 -> 2166 bytes icons/ApPalm_32x32_256.bmp | Bin 0 -> 2102 bytes icons/ApPalm_32x32_4grey.bmp | Bin 0 -> 630 bytes icons/ApPalm_32x32_B&W.bmp | Bin 0 -> 190 bytes palmapple/6502.c | 1960 ++++++++++++++++++++++++++++ palmapple/6502.h | 9 + palmapple/fonts.c | 137 ++ palmapple/fonts/char00.bmp | 3 + palmapple/fonts/char01.bmp | 3 + palmapple/fonts/char02.bmp | 3 + palmapple/fonts/char03.bmp | 3 + palmapple/fonts/char04.bmp | 3 + palmapple/fonts/char05.bmp | 3 + palmapple/fonts/char06.bmp | 3 + palmapple/fonts/char07.bmp | 3 + palmapple/fonts/char08.bmp | 3 + palmapple/fonts/char09.bmp | 3 + palmapple/fonts/char0a.bmp | 3 + palmapple/fonts/char0b.bmp | 3 + palmapple/fonts/char0c.bmp | 3 + palmapple/fonts/char0d.bmp | 3 + palmapple/fonts/char0e.bmp | 3 + palmapple/fonts/char0f.bmp | 3 + palmapple/fonts/char10.bmp | 3 + palmapple/fonts/char11.bmp | 3 + palmapple/fonts/char12.bmp | 3 + palmapple/fonts/char13.bmp | 3 + palmapple/fonts/char14.bmp | 3 + palmapple/fonts/char15.bmp | 3 + palmapple/fonts/char16.bmp | 3 + palmapple/fonts/char17.bmp | 3 + palmapple/fonts/char18.bmp | 3 + palmapple/fonts/char19.bmp | 3 + palmapple/fonts/char1a.bmp | 3 + palmapple/fonts/char1b.bmp | 3 + palmapple/fonts/char1c.bmp | 3 + palmapple/fonts/char1d.bmp | 3 + palmapple/fonts/char1e.bmp | 3 + palmapple/fonts/char1f.bmp | 3 + palmapple/fonts/char20.bmp | 3 + palmapple/fonts/char21.bmp | 3 + palmapple/fonts/char22.bmp | 3 + palmapple/fonts/char23.bmp | 3 + palmapple/fonts/char24.bmp | 3 + palmapple/fonts/char25.bmp | 3 + palmapple/fonts/char26.bmp | 3 + palmapple/fonts/char27.bmp | 3 + palmapple/fonts/char28.bmp | 3 + palmapple/fonts/char29.bmp | 3 + palmapple/fonts/char2a.bmp | 3 + palmapple/fonts/char2b.bmp | 3 + palmapple/fonts/char2c.bmp | 3 + palmapple/fonts/char2d.bmp | 3 + palmapple/fonts/char2e.bmp | 3 + palmapple/fonts/char2f.bmp | 3 + palmapple/fonts/char30.bmp | 3 + palmapple/fonts/char31.bmp | 3 + palmapple/fonts/char32.bmp | 3 + palmapple/fonts/char33.bmp | 3 + palmapple/fonts/char34.bmp | 3 + palmapple/fonts/char35.bmp | 3 + palmapple/fonts/char36.bmp | 3 + palmapple/fonts/char37.bmp | 3 + palmapple/fonts/char38.bmp | 3 + palmapple/fonts/char39.bmp | 3 + palmapple/fonts/char3a.bmp | 3 + palmapple/fonts/char3b.bmp | 3 + palmapple/fonts/char3c.bmp | 3 + palmapple/fonts/char3d.bmp | 3 + palmapple/fonts/char3e.bmp | 3 + palmapple/fonts/char3f.bmp | 3 + palmapple/fonts/char40.bmp | 3 + palmapple/fonts/char41.bmp | 3 + palmapple/fonts/char42.bmp | 3 + palmapple/fonts/char43.bmp | 3 + palmapple/fonts/char44.bmp | 3 + palmapple/fonts/char45.bmp | 3 + palmapple/fonts/char46.bmp | 3 + palmapple/fonts/char47.bmp | 3 + palmapple/fonts/char48.bmp | 3 + palmapple/fonts/char49.bmp | 3 + palmapple/fonts/char4a.bmp | 3 + palmapple/fonts/char4b.bmp | 3 + palmapple/fonts/char4c.bmp | 3 + palmapple/fonts/char4d.bmp | 3 + palmapple/fonts/char4e.bmp | 3 + palmapple/fonts/char4f.bmp | 3 + palmapple/fonts/char50.bmp | 3 + palmapple/fonts/char51.bmp | 3 + palmapple/fonts/char52.bmp | 3 + palmapple/fonts/char53.bmp | 3 + palmapple/fonts/char54.bmp | 3 + palmapple/fonts/char55.bmp | 3 + palmapple/fonts/char56.bmp | 3 + palmapple/fonts/char57.bmp | 3 + palmapple/fonts/char58.bmp | 3 + palmapple/fonts/char59.bmp | 3 + palmapple/fonts/char5a.bmp | 3 + palmapple/fonts/char5b.bmp | 3 + palmapple/fonts/char5c.bmp | 3 + palmapple/fonts/char5d.bmp | 3 + palmapple/fonts/char5e.bmp | 3 + palmapple/fonts/char5f.bmp | 3 + palmapple/fonts/lowres.bmp | 3 + palmapple/iou.h | 113 ++ palmapple/memory.c | 899 +++++++++++++ palmapple/memory.h | 2 + palmapple/palmapple.c | 164 +++ readme | 85 ++ src/6502.asm | 2122 +++++++++++++++++++++++++++++++ src/6502.h | 117 ++ src/Apple2.h | 193 +++ src/a2mgr.c | 219 ++++ src/a2mgr.rcp | 38 + src/a2mgr_rsc.h | 19 + src/appalm.c | 1250 ++++++++++++++++++ src/appalm.rcp | 112 ++ src/appalm_rsc.h | 67 + src/fonts4x6.c | 137 ++ src/fonts4x6/CVS/Entries | 97 ++ src/fonts4x6/CVS/Repository | 1 + src/fonts4x6/CVS/Root | 1 + src/fonts4x6/char00.bmp | 3 + src/fonts4x6/char01.bmp | 3 + src/fonts4x6/char02.bmp | 3 + src/fonts4x6/char03.bmp | 3 + src/fonts4x6/char04.bmp | 3 + src/fonts4x6/char05.bmp | 3 + src/fonts4x6/char06.bmp | 3 + src/fonts4x6/char07.bmp | 3 + src/fonts4x6/char08.bmp | 3 + src/fonts4x6/char09.bmp | 3 + src/fonts4x6/char0a.bmp | 3 + src/fonts4x6/char0b.bmp | 3 + src/fonts4x6/char0c.bmp | 3 + src/fonts4x6/char0d.bmp | 3 + src/fonts4x6/char0e.bmp | 3 + src/fonts4x6/char0f.bmp | 3 + src/fonts4x6/char10.bmp | 3 + src/fonts4x6/char11.bmp | 3 + src/fonts4x6/char12.bmp | 3 + src/fonts4x6/char13.bmp | 3 + src/fonts4x6/char14.bmp | 3 + src/fonts4x6/char15.bmp | 3 + src/fonts4x6/char16.bmp | 3 + src/fonts4x6/char17.bmp | 3 + src/fonts4x6/char18.bmp | 3 + src/fonts4x6/char19.bmp | 3 + src/fonts4x6/char1a.bmp | 3 + src/fonts4x6/char1b.bmp | 3 + src/fonts4x6/char1c.bmp | 3 + src/fonts4x6/char1d.bmp | 3 + src/fonts4x6/char1e.bmp | 3 + src/fonts4x6/char1f.bmp | 3 + src/fonts4x6/char20.bmp | 3 + src/fonts4x6/char21.bmp | 3 + src/fonts4x6/char22.bmp | 3 + src/fonts4x6/char23.bmp | 3 + src/fonts4x6/char24.bmp | 3 + src/fonts4x6/char25.bmp | 3 + src/fonts4x6/char26.bmp | 3 + src/fonts4x6/char27.bmp | 3 + src/fonts4x6/char28.bmp | 3 + src/fonts4x6/char29.bmp | 3 + src/fonts4x6/char2a.bmp | 3 + src/fonts4x6/char2b.bmp | 3 + src/fonts4x6/char2c.bmp | 3 + src/fonts4x6/char2d.bmp | 3 + src/fonts4x6/char2e.bmp | 3 + src/fonts4x6/char2f.bmp | 3 + src/fonts4x6/char30.bmp | 3 + src/fonts4x6/char31.bmp | 3 + src/fonts4x6/char32.bmp | 3 + src/fonts4x6/char33.bmp | 3 + src/fonts4x6/char34.bmp | 3 + src/fonts4x6/char35.bmp | 3 + src/fonts4x6/char36.bmp | 3 + src/fonts4x6/char37.bmp | 3 + src/fonts4x6/char38.bmp | 3 + src/fonts4x6/char39.bmp | 3 + src/fonts4x6/char3a.bmp | 3 + src/fonts4x6/char3b.bmp | 3 + src/fonts4x6/char3c.bmp | 3 + src/fonts4x6/char3d.bmp | 3 + src/fonts4x6/char3e.bmp | 3 + src/fonts4x6/char3f.bmp | 3 + src/fonts4x6/char40.bmp | 3 + src/fonts4x6/char41.bmp | 3 + src/fonts4x6/char42.bmp | 3 + src/fonts4x6/char43.bmp | 3 + src/fonts4x6/char44.bmp | 3 + src/fonts4x6/char45.bmp | 3 + src/fonts4x6/char46.bmp | 3 + src/fonts4x6/char47.bmp | 3 + src/fonts4x6/char48.bmp | 3 + src/fonts4x6/char49.bmp | 3 + src/fonts4x6/char4a.bmp | 3 + src/fonts4x6/char4b.bmp | 3 + src/fonts4x6/char4c.bmp | 3 + src/fonts4x6/char4d.bmp | 3 + src/fonts4x6/char4e.bmp | 3 + src/fonts4x6/char4f.bmp | 3 + src/fonts4x6/char50.bmp | 3 + src/fonts4x6/char51.bmp | 3 + src/fonts4x6/char52.bmp | 3 + src/fonts4x6/char53.bmp | 3 + src/fonts4x6/char54.bmp | 3 + src/fonts4x6/char55.bmp | 3 + src/fonts4x6/char56.bmp | 3 + src/fonts4x6/char57.bmp | 3 + src/fonts4x6/char58.bmp | 3 + src/fonts4x6/char59.bmp | 3 + src/fonts4x6/char5a.bmp | 3 + src/fonts4x6/char5b.bmp | 3 + src/fonts4x6/char5c.bmp | 3 + src/fonts4x6/char5d.bmp | 3 + src/fonts4x6/char5e.bmp | 3 + src/fonts4x6/char5f.bmp | 3 + src/fonts7x8.c | 137 ++ src/fonts7x8/CVS/Entries | 98 ++ src/fonts7x8/CVS/Repository | 1 + src/fonts7x8/CVS/Root | 1 + src/fonts7x8/char00.bmp | 3 + src/fonts7x8/char01.bmp | 3 + src/fonts7x8/char02.bmp | 3 + src/fonts7x8/char03.bmp | 3 + src/fonts7x8/char04.bmp | 3 + src/fonts7x8/char05.bmp | 3 + src/fonts7x8/char06.bmp | 3 + src/fonts7x8/char07.bmp | 3 + src/fonts7x8/char08.bmp | 3 + src/fonts7x8/char09.bmp | 3 + src/fonts7x8/char0a.bmp | 3 + src/fonts7x8/char0b.bmp | 3 + src/fonts7x8/char0c.bmp | 3 + src/fonts7x8/char0d.bmp | 3 + src/fonts7x8/char0e.bmp | 3 + src/fonts7x8/char0f.bmp | 3 + src/fonts7x8/char10.bmp | 3 + src/fonts7x8/char11.bmp | 3 + src/fonts7x8/char12.bmp | 3 + src/fonts7x8/char13.bmp | 3 + src/fonts7x8/char14.bmp | 3 + src/fonts7x8/char15.bmp | 3 + src/fonts7x8/char16.bmp | 3 + src/fonts7x8/char17.bmp | 3 + src/fonts7x8/char18.bmp | 3 + src/fonts7x8/char19.bmp | 3 + src/fonts7x8/char1a.bmp | 3 + src/fonts7x8/char1b.bmp | 3 + src/fonts7x8/char1c.bmp | 3 + src/fonts7x8/char1d.bmp | 3 + src/fonts7x8/char1e.bmp | 3 + src/fonts7x8/char1f.bmp | 3 + src/fonts7x8/char20.bmp | 3 + src/fonts7x8/char21.bmp | 3 + src/fonts7x8/char22.bmp | 3 + src/fonts7x8/char23.bmp | 3 + src/fonts7x8/char24.bmp | 3 + src/fonts7x8/char25.bmp | 3 + src/fonts7x8/char26.bmp | 3 + src/fonts7x8/char27.bmp | 3 + src/fonts7x8/char28.bmp | 3 + src/fonts7x8/char29.bmp | 3 + src/fonts7x8/char2a.bmp | 3 + src/fonts7x8/char2b.bmp | 3 + src/fonts7x8/char2c.bmp | 3 + src/fonts7x8/char2d.bmp | 3 + src/fonts7x8/char2e.bmp | 3 + src/fonts7x8/char2f.bmp | 3 + src/fonts7x8/char30.bmp | 3 + src/fonts7x8/char31.bmp | 3 + src/fonts7x8/char32.bmp | 3 + src/fonts7x8/char33.bmp | 3 + src/fonts7x8/char34.bmp | 3 + src/fonts7x8/char35.bmp | 3 + src/fonts7x8/char36.bmp | 3 + src/fonts7x8/char37.bmp | 3 + src/fonts7x8/char38.bmp | 3 + src/fonts7x8/char39.bmp | 3 + src/fonts7x8/char3a.bmp | 3 + src/fonts7x8/char3b.bmp | 3 + src/fonts7x8/char3c.bmp | 3 + src/fonts7x8/char3d.bmp | 3 + src/fonts7x8/char3e.bmp | 3 + src/fonts7x8/char3f.bmp | 3 + src/fonts7x8/char40.bmp | 3 + src/fonts7x8/char41.bmp | 3 + src/fonts7x8/char42.bmp | 3 + src/fonts7x8/char43.bmp | 3 + src/fonts7x8/char44.bmp | 3 + src/fonts7x8/char45.bmp | 3 + src/fonts7x8/char46.bmp | 3 + src/fonts7x8/char47.bmp | 3 + src/fonts7x8/char48.bmp | 3 + src/fonts7x8/char49.bmp | 3 + src/fonts7x8/char4a.bmp | 3 + src/fonts7x8/char4b.bmp | 3 + src/fonts7x8/char4c.bmp | 3 + src/fonts7x8/char4d.bmp | 3 + src/fonts7x8/char4e.bmp | 3 + src/fonts7x8/char4f.bmp | 3 + src/fonts7x8/char50.bmp | 3 + src/fonts7x8/char51.bmp | 3 + src/fonts7x8/char52.bmp | 3 + src/fonts7x8/char53.bmp | 3 + src/fonts7x8/char54.bmp | 3 + src/fonts7x8/char55.bmp | 3 + src/fonts7x8/char56.bmp | 3 + src/fonts7x8/char57.bmp | 3 + src/fonts7x8/char58.bmp | 3 + src/fonts7x8/char59.bmp | 3 + src/fonts7x8/char5a.bmp | 3 + src/fonts7x8/char5b.bmp | 3 + src/fonts7x8/char5c.bmp | 3 + src/fonts7x8/char5d.bmp | 3 + src/fonts7x8/char5e.bmp | 3 + src/fonts7x8/char5f.bmp | 3 + src/fonts7x8/lowres.bmp | 3 + src/iou.h | 111 ++ src/memio.c | 1802 ++++++++++++++++++++++++++ src/memory.h | 71 ++ src/vidclr.asm | 816 ++++++++++++ src/video.c | 1153 +++++++++++++++++ utils/dsk2pdb.c | 685 ++++++++++ utils/rom2pdb.c | 140 ++ 336 files changed, 13748 insertions(+) create mode 100644 Makefile create mode 100644 icons/ApPalm_13x9_256.bmp create mode 100644 icons/ApPalm_15x9_16grey.bmp create mode 100644 icons/ApPalm_15x9_256.bmp create mode 100644 icons/ApPalm_15x9_4grey.bmp create mode 100644 icons/ApPalm_15x9_B&W.bmp create mode 100644 icons/ApPalm_32x22_16grey.bmp create mode 100644 icons/ApPalm_32x22_256.bmp create mode 100644 icons/ApPalm_32x22_4grey.bmp create mode 100644 icons/ApPalm_32x22_B&W.bmp create mode 100644 icons/ApPalm_32x22_original.bmp create mode 100644 icons/ApPalm_32x32_256.bmp create mode 100644 icons/ApPalm_32x32_4grey.bmp create mode 100644 icons/ApPalm_32x32_B&W.bmp create mode 100644 palmapple/6502.c create mode 100644 palmapple/6502.h create mode 100644 palmapple/fonts.c create mode 100644 palmapple/fonts/char00.bmp create mode 100644 palmapple/fonts/char01.bmp create mode 100644 palmapple/fonts/char02.bmp create mode 100644 palmapple/fonts/char03.bmp create mode 100644 palmapple/fonts/char04.bmp create mode 100644 palmapple/fonts/char05.bmp create mode 100644 palmapple/fonts/char06.bmp create mode 100644 palmapple/fonts/char07.bmp create mode 100644 palmapple/fonts/char08.bmp create mode 100644 palmapple/fonts/char09.bmp create mode 100644 palmapple/fonts/char0a.bmp create mode 100644 palmapple/fonts/char0b.bmp create mode 100644 palmapple/fonts/char0c.bmp create mode 100644 palmapple/fonts/char0d.bmp create mode 100644 palmapple/fonts/char0e.bmp create mode 100644 palmapple/fonts/char0f.bmp create mode 100644 palmapple/fonts/char10.bmp create mode 100644 palmapple/fonts/char11.bmp create mode 100644 palmapple/fonts/char12.bmp create mode 100644 palmapple/fonts/char13.bmp create mode 100644 palmapple/fonts/char14.bmp create mode 100644 palmapple/fonts/char15.bmp create mode 100644 palmapple/fonts/char16.bmp create mode 100644 palmapple/fonts/char17.bmp create mode 100644 palmapple/fonts/char18.bmp create mode 100644 palmapple/fonts/char19.bmp create mode 100644 palmapple/fonts/char1a.bmp create mode 100644 palmapple/fonts/char1b.bmp create mode 100644 palmapple/fonts/char1c.bmp create mode 100644 palmapple/fonts/char1d.bmp create mode 100644 palmapple/fonts/char1e.bmp create mode 100644 palmapple/fonts/char1f.bmp create mode 100644 palmapple/fonts/char20.bmp create mode 100644 palmapple/fonts/char21.bmp create mode 100644 palmapple/fonts/char22.bmp create mode 100644 palmapple/fonts/char23.bmp create mode 100644 palmapple/fonts/char24.bmp create mode 100644 palmapple/fonts/char25.bmp create mode 100644 palmapple/fonts/char26.bmp create mode 100644 palmapple/fonts/char27.bmp create mode 100644 palmapple/fonts/char28.bmp create mode 100644 palmapple/fonts/char29.bmp create mode 100644 palmapple/fonts/char2a.bmp create mode 100644 palmapple/fonts/char2b.bmp create mode 100644 palmapple/fonts/char2c.bmp create mode 100644 palmapple/fonts/char2d.bmp create mode 100644 palmapple/fonts/char2e.bmp create mode 100644 palmapple/fonts/char2f.bmp create mode 100644 palmapple/fonts/char30.bmp create mode 100644 palmapple/fonts/char31.bmp create mode 100644 palmapple/fonts/char32.bmp create mode 100644 palmapple/fonts/char33.bmp create mode 100644 palmapple/fonts/char34.bmp create mode 100644 palmapple/fonts/char35.bmp create mode 100644 palmapple/fonts/char36.bmp create mode 100644 palmapple/fonts/char37.bmp create mode 100644 palmapple/fonts/char38.bmp create mode 100644 palmapple/fonts/char39.bmp create mode 100644 palmapple/fonts/char3a.bmp create mode 100644 palmapple/fonts/char3b.bmp create mode 100644 palmapple/fonts/char3c.bmp create mode 100644 palmapple/fonts/char3d.bmp create mode 100644 palmapple/fonts/char3e.bmp create mode 100644 palmapple/fonts/char3f.bmp create mode 100644 palmapple/fonts/char40.bmp create mode 100644 palmapple/fonts/char41.bmp create mode 100644 palmapple/fonts/char42.bmp create mode 100644 palmapple/fonts/char43.bmp create mode 100644 palmapple/fonts/char44.bmp create mode 100644 palmapple/fonts/char45.bmp create mode 100644 palmapple/fonts/char46.bmp create mode 100644 palmapple/fonts/char47.bmp create mode 100644 palmapple/fonts/char48.bmp create mode 100644 palmapple/fonts/char49.bmp create mode 100644 palmapple/fonts/char4a.bmp create mode 100644 palmapple/fonts/char4b.bmp create mode 100644 palmapple/fonts/char4c.bmp create mode 100644 palmapple/fonts/char4d.bmp create mode 100644 palmapple/fonts/char4e.bmp create mode 100644 palmapple/fonts/char4f.bmp create mode 100644 palmapple/fonts/char50.bmp create mode 100644 palmapple/fonts/char51.bmp create mode 100644 palmapple/fonts/char52.bmp create mode 100644 palmapple/fonts/char53.bmp create mode 100644 palmapple/fonts/char54.bmp create mode 100644 palmapple/fonts/char55.bmp create mode 100644 palmapple/fonts/char56.bmp create mode 100644 palmapple/fonts/char57.bmp create mode 100644 palmapple/fonts/char58.bmp create mode 100644 palmapple/fonts/char59.bmp create mode 100644 palmapple/fonts/char5a.bmp create mode 100644 palmapple/fonts/char5b.bmp create mode 100644 palmapple/fonts/char5c.bmp create mode 100644 palmapple/fonts/char5d.bmp create mode 100644 palmapple/fonts/char5e.bmp create mode 100644 palmapple/fonts/char5f.bmp create mode 100644 palmapple/fonts/lowres.bmp create mode 100644 palmapple/iou.h create mode 100644 palmapple/memory.c create mode 100644 palmapple/memory.h create mode 100644 palmapple/palmapple.c create mode 100755 readme create mode 100755 src/6502.asm create mode 100755 src/6502.h create mode 100755 src/Apple2.h create mode 100755 src/a2mgr.c create mode 100755 src/a2mgr.rcp create mode 100755 src/a2mgr_rsc.h create mode 100755 src/appalm.c create mode 100755 src/appalm.rcp create mode 100755 src/appalm_rsc.h create mode 100755 src/fonts4x6.c create mode 100644 src/fonts4x6/CVS/Entries create mode 100644 src/fonts4x6/CVS/Repository create mode 100644 src/fonts4x6/CVS/Root create mode 100755 src/fonts4x6/char00.bmp create mode 100755 src/fonts4x6/char01.bmp create mode 100755 src/fonts4x6/char02.bmp create mode 100755 src/fonts4x6/char03.bmp create mode 100755 src/fonts4x6/char04.bmp create mode 100755 src/fonts4x6/char05.bmp create mode 100755 src/fonts4x6/char06.bmp create mode 100755 src/fonts4x6/char07.bmp create mode 100755 src/fonts4x6/char08.bmp create mode 100755 src/fonts4x6/char09.bmp create mode 100755 src/fonts4x6/char0a.bmp create mode 100755 src/fonts4x6/char0b.bmp create mode 100755 src/fonts4x6/char0c.bmp create mode 100755 src/fonts4x6/char0d.bmp create mode 100755 src/fonts4x6/char0e.bmp create mode 100755 src/fonts4x6/char0f.bmp create mode 100755 src/fonts4x6/char10.bmp create mode 100755 src/fonts4x6/char11.bmp create mode 100755 src/fonts4x6/char12.bmp create mode 100755 src/fonts4x6/char13.bmp create mode 100755 src/fonts4x6/char14.bmp create mode 100755 src/fonts4x6/char15.bmp create mode 100755 src/fonts4x6/char16.bmp create mode 100755 src/fonts4x6/char17.bmp create mode 100755 src/fonts4x6/char18.bmp create mode 100755 src/fonts4x6/char19.bmp create mode 100755 src/fonts4x6/char1a.bmp create mode 100755 src/fonts4x6/char1b.bmp create mode 100755 src/fonts4x6/char1c.bmp create mode 100755 src/fonts4x6/char1d.bmp create mode 100755 src/fonts4x6/char1e.bmp create mode 100755 src/fonts4x6/char1f.bmp create mode 100755 src/fonts4x6/char20.bmp create mode 100755 src/fonts4x6/char21.bmp create mode 100755 src/fonts4x6/char22.bmp create mode 100755 src/fonts4x6/char23.bmp create mode 100755 src/fonts4x6/char24.bmp create mode 100755 src/fonts4x6/char25.bmp create mode 100755 src/fonts4x6/char26.bmp create mode 100755 src/fonts4x6/char27.bmp create mode 100755 src/fonts4x6/char28.bmp create mode 100755 src/fonts4x6/char29.bmp create mode 100755 src/fonts4x6/char2a.bmp create mode 100755 src/fonts4x6/char2b.bmp create mode 100755 src/fonts4x6/char2c.bmp create mode 100755 src/fonts4x6/char2d.bmp create mode 100755 src/fonts4x6/char2e.bmp create mode 100755 src/fonts4x6/char2f.bmp create mode 100755 src/fonts4x6/char30.bmp create mode 100755 src/fonts4x6/char31.bmp create mode 100755 src/fonts4x6/char32.bmp create mode 100755 src/fonts4x6/char33.bmp create mode 100755 src/fonts4x6/char34.bmp create mode 100755 src/fonts4x6/char35.bmp create mode 100755 src/fonts4x6/char36.bmp create mode 100755 src/fonts4x6/char37.bmp create mode 100755 src/fonts4x6/char38.bmp create mode 100755 src/fonts4x6/char39.bmp create mode 100755 src/fonts4x6/char3a.bmp create mode 100755 src/fonts4x6/char3b.bmp create mode 100755 src/fonts4x6/char3c.bmp create mode 100755 src/fonts4x6/char3d.bmp create mode 100755 src/fonts4x6/char3e.bmp create mode 100755 src/fonts4x6/char3f.bmp create mode 100755 src/fonts4x6/char40.bmp create mode 100755 src/fonts4x6/char41.bmp create mode 100755 src/fonts4x6/char42.bmp create mode 100755 src/fonts4x6/char43.bmp create mode 100755 src/fonts4x6/char44.bmp create mode 100755 src/fonts4x6/char45.bmp create mode 100755 src/fonts4x6/char46.bmp create mode 100755 src/fonts4x6/char47.bmp create mode 100755 src/fonts4x6/char48.bmp create mode 100755 src/fonts4x6/char49.bmp create mode 100755 src/fonts4x6/char4a.bmp create mode 100755 src/fonts4x6/char4b.bmp create mode 100755 src/fonts4x6/char4c.bmp create mode 100755 src/fonts4x6/char4d.bmp create mode 100755 src/fonts4x6/char4e.bmp create mode 100755 src/fonts4x6/char4f.bmp create mode 100755 src/fonts4x6/char50.bmp create mode 100755 src/fonts4x6/char51.bmp create mode 100755 src/fonts4x6/char52.bmp create mode 100755 src/fonts4x6/char53.bmp create mode 100755 src/fonts4x6/char54.bmp create mode 100755 src/fonts4x6/char55.bmp create mode 100755 src/fonts4x6/char56.bmp create mode 100755 src/fonts4x6/char57.bmp create mode 100755 src/fonts4x6/char58.bmp create mode 100755 src/fonts4x6/char59.bmp create mode 100755 src/fonts4x6/char5a.bmp create mode 100755 src/fonts4x6/char5b.bmp create mode 100755 src/fonts4x6/char5c.bmp create mode 100755 src/fonts4x6/char5d.bmp create mode 100755 src/fonts4x6/char5e.bmp create mode 100755 src/fonts4x6/char5f.bmp create mode 100755 src/fonts7x8.c create mode 100644 src/fonts7x8/CVS/Entries create mode 100644 src/fonts7x8/CVS/Repository create mode 100644 src/fonts7x8/CVS/Root create mode 100755 src/fonts7x8/char00.bmp create mode 100755 src/fonts7x8/char01.bmp create mode 100755 src/fonts7x8/char02.bmp create mode 100755 src/fonts7x8/char03.bmp create mode 100755 src/fonts7x8/char04.bmp create mode 100755 src/fonts7x8/char05.bmp create mode 100755 src/fonts7x8/char06.bmp create mode 100755 src/fonts7x8/char07.bmp create mode 100755 src/fonts7x8/char08.bmp create mode 100755 src/fonts7x8/char09.bmp create mode 100755 src/fonts7x8/char0a.bmp create mode 100755 src/fonts7x8/char0b.bmp create mode 100755 src/fonts7x8/char0c.bmp create mode 100755 src/fonts7x8/char0d.bmp create mode 100755 src/fonts7x8/char0e.bmp create mode 100755 src/fonts7x8/char0f.bmp create mode 100755 src/fonts7x8/char10.bmp create mode 100755 src/fonts7x8/char11.bmp create mode 100755 src/fonts7x8/char12.bmp create mode 100755 src/fonts7x8/char13.bmp create mode 100755 src/fonts7x8/char14.bmp create mode 100755 src/fonts7x8/char15.bmp create mode 100755 src/fonts7x8/char16.bmp create mode 100755 src/fonts7x8/char17.bmp create mode 100755 src/fonts7x8/char18.bmp create mode 100755 src/fonts7x8/char19.bmp create mode 100755 src/fonts7x8/char1a.bmp create mode 100755 src/fonts7x8/char1b.bmp create mode 100755 src/fonts7x8/char1c.bmp create mode 100755 src/fonts7x8/char1d.bmp create mode 100755 src/fonts7x8/char1e.bmp create mode 100755 src/fonts7x8/char1f.bmp create mode 100755 src/fonts7x8/char20.bmp create mode 100755 src/fonts7x8/char21.bmp create mode 100755 src/fonts7x8/char22.bmp create mode 100755 src/fonts7x8/char23.bmp create mode 100755 src/fonts7x8/char24.bmp create mode 100755 src/fonts7x8/char25.bmp create mode 100755 src/fonts7x8/char26.bmp create mode 100755 src/fonts7x8/char27.bmp create mode 100755 src/fonts7x8/char28.bmp create mode 100755 src/fonts7x8/char29.bmp create mode 100755 src/fonts7x8/char2a.bmp create mode 100755 src/fonts7x8/char2b.bmp create mode 100755 src/fonts7x8/char2c.bmp create mode 100755 src/fonts7x8/char2d.bmp create mode 100755 src/fonts7x8/char2e.bmp create mode 100755 src/fonts7x8/char2f.bmp create mode 100755 src/fonts7x8/char30.bmp create mode 100755 src/fonts7x8/char31.bmp create mode 100755 src/fonts7x8/char32.bmp create mode 100755 src/fonts7x8/char33.bmp create mode 100755 src/fonts7x8/char34.bmp create mode 100755 src/fonts7x8/char35.bmp create mode 100755 src/fonts7x8/char36.bmp create mode 100755 src/fonts7x8/char37.bmp create mode 100755 src/fonts7x8/char38.bmp create mode 100755 src/fonts7x8/char39.bmp create mode 100755 src/fonts7x8/char3a.bmp create mode 100755 src/fonts7x8/char3b.bmp create mode 100755 src/fonts7x8/char3c.bmp create mode 100755 src/fonts7x8/char3d.bmp create mode 100755 src/fonts7x8/char3e.bmp create mode 100755 src/fonts7x8/char3f.bmp create mode 100755 src/fonts7x8/char40.bmp create mode 100755 src/fonts7x8/char41.bmp create mode 100755 src/fonts7x8/char42.bmp create mode 100755 src/fonts7x8/char43.bmp create mode 100755 src/fonts7x8/char44.bmp create mode 100755 src/fonts7x8/char45.bmp create mode 100755 src/fonts7x8/char46.bmp create mode 100755 src/fonts7x8/char47.bmp create mode 100755 src/fonts7x8/char48.bmp create mode 100755 src/fonts7x8/char49.bmp create mode 100755 src/fonts7x8/char4a.bmp create mode 100755 src/fonts7x8/char4b.bmp create mode 100755 src/fonts7x8/char4c.bmp create mode 100755 src/fonts7x8/char4d.bmp create mode 100755 src/fonts7x8/char4e.bmp create mode 100755 src/fonts7x8/char4f.bmp create mode 100755 src/fonts7x8/char50.bmp create mode 100755 src/fonts7x8/char51.bmp create mode 100755 src/fonts7x8/char52.bmp create mode 100755 src/fonts7x8/char53.bmp create mode 100755 src/fonts7x8/char54.bmp create mode 100755 src/fonts7x8/char55.bmp create mode 100755 src/fonts7x8/char56.bmp create mode 100755 src/fonts7x8/char57.bmp create mode 100755 src/fonts7x8/char58.bmp create mode 100755 src/fonts7x8/char59.bmp create mode 100755 src/fonts7x8/char5a.bmp create mode 100755 src/fonts7x8/char5b.bmp create mode 100755 src/fonts7x8/char5c.bmp create mode 100755 src/fonts7x8/char5d.bmp create mode 100755 src/fonts7x8/char5e.bmp create mode 100755 src/fonts7x8/char5f.bmp create mode 100755 src/fonts7x8/lowres.bmp create mode 100755 src/iou.h create mode 100755 src/memio.c create mode 100755 src/memory.h create mode 100755 src/vidclr.asm create mode 100755 src/video.c create mode 100755 utils/dsk2pdb.c create mode 100755 utils/rom2pdb.c diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..48910b7 --- /dev/null +++ b/Makefile @@ -0,0 +1,121 @@ +# Make File for Apple IIe Emulator for PalmOS 3.1 +VERSION_MAJOR =0 +VERSION_MINOR =7.3 +CFLAGS = -Os +# -g -gstabs +# -DDEBUG +AFLAGS = -m68000 -pic -disp-size-default-16 +# -D --gstabs + +INCLUDES = +APPALM_OBJS = obj/appalm.o obj/6502.o obj/memio.o obj/video.o obj/vidclr.o obj/fonts7x8.o obj/fonts4x6.o +APPALM_BINS = obj/MBAR0bb8.bin obj/tAIB03e8.bin obj/tAIB03e9.bin obj/Talt08fc.bin obj/Talt09c4.bin obj/Talt0a28.bin obj/tFRM03e8.bin obj/tFRM044c.bin obj/tFRM04b0.bin obj/tver03e8.bin +APPALM_M68KEXECUTABLE = obj/appalm +APPALM = appalm.prc +A2MGR_OBJS = obj/a2mgr.o +A2MGR_BINS = obj/tAIB03e8.bin obj/tAIB03e9.bin obj/Talt238c.bin obj/Talt23f0.bin obj/tFRM2328.bin obj/tver03e8.bin +A2MGR_M68KEXECUTABLE = obj/a2mgr +A2MGR = a2mgr.prc +DSK2PDB = utils/dsk2pdb + +BUILDPRC = build-prc +PILRC = pilrc -I src +GCC = m68k-palmos-gcc +AS = m68k-palmos-as +TAR = tar +ZIP = zip + +all: $(APPALM) $(A2MGR) $(DSK2PDB) + +clean: cleansrc cleanobj + +cleansrc: + rm -f src/*.c~ + rm -f src/*.h~ + rm -f src/*.bak + rm -f src/tags + rm -f utils/dsk2pdb + rm -f tags + +cleanobj: + rm -f obj/*.o + rm -f obj/*.s + rm -f obj/*.bin + rm -f obj/*.stamp + rm -f $(APPALM_M68KEXECUTABLE) + rm -f $(APPALM) + rm -f $(A2MGR_M68KEXECUTABLE) + rm -f $(A2MGR) + +dist: + mkdir appalm-$(VERSION_MAJOR).$(VERSION_MINOR) + mkdir appalm-$(VERSION_MAJOR).$(VERSION_MINOR)/src + mkdir appalm-$(VERSION_MAJOR).$(VERSION_MINOR)/src/fonts4x6 + mkdir appalm-$(VERSION_MAJOR).$(VERSION_MINOR)/src/fonts7x8 + mkdir appalm-$(VERSION_MAJOR).$(VERSION_MINOR)/obj + mkdir appalm-$(VERSION_MAJOR).$(VERSION_MINOR)/utils + cp src/*.c appalm-$(VERSION_MAJOR).$(VERSION_MINOR)/src + cp src/*.h appalm-$(VERSION_MAJOR).$(VERSION_MINOR)/src + cp src/*.asm appalm-$(VERSION_MAJOR).$(VERSION_MINOR)/src + cp src/*.rcp appalm-$(VERSION_MAJOR).$(VERSION_MINOR)/src + cp src/fonts4x6/*.bmp appalm-$(VERSION_MAJOR).$(VERSION_MINOR)/src/fonts4x6 + cp src/fonts7x8/*.bmp appalm-$(VERSION_MAJOR).$(VERSION_MINOR)/src/fonts7x8 + cp utils/*.c appalm-$(VERSION_MAJOR).$(VERSION_MINOR)/utils + cp Makefile appalm-$(VERSION_MAJOR).$(VERSION_MINOR) + cp README appalm-$(VERSION_MAJOR).$(VERSION_MINOR) + $(TAR) czf appalm-$(VERSION_MAJOR).$(VERSION_MINOR).tar.gz appalm-$(VERSION_MAJOR).$(VERSION_MINOR) + $(ZIP) appalm-$(VERSION_MAJOR).$(VERSION_MINOR).zip appalm-$(VERSION_MAJOR).$(VERSION_MINOR) + rm -rf appalm-$(VERSION_MAJOR).$(VERSION_MINOR) + +$(DSK2PDB): utils/dsk2pdb.c + gcc -o $(DSK2PDB) $< + +$(APPALM): $(APPALM_M68KEXECUTABLE) obj/appalm.bin.stamp + $(BUILDPRC) $(APPALM) "Appalm ][" Aple2 $(APPALM_M68KEXECUTABLE) $(APPALM_BINS) + +$(APPALM_M68KEXECUTABLE): $(APPALM_OBJS) + $(GCC) $(CFLAGS) -o $(APPALM_M68KEXECUTABLE) $(APPALM_OBJS) + +obj/appalm.bin.stamp: src/appalm.rcp + $(PILRC) $^ obj + touch $@ + +obj/appalm.o: src/appalm.c src/Apple2.h src/6502.h src/memory.h + $(GCC) $(CFLAGS) -S $< -o $*.s + $(GCC) $(CFLAGS) -c $< -o $*.o + +obj/6502.o: src/6502.asm src/6502.h + cpp -E $< > $*.s + $(AS) $(AFLAGS) $*.s -o $*.o + +obj/memio.o: src/memio.c src/memory.h src/iou.h + $(GCC) $(CFLAGS) -S $< -o $*.s + $(GCC) $(CFLAGS) -c $< -o $*.o + +obj/video.o: src/video.c src/memory.h src/iou.h + $(GCC) $(CFLAGS) -S $< -o $*.s + $(GCC) $(CFLAGS) -c $< -o $*.o + +obj/vidclr.o: src/vidclr.asm + cpp -E $< > $*.s + $(AS) $(AFLAGS) $*.s -o $*.o + +obj/fonts7x8.o: src/fonts7x8.c + $(GCC) $(CFLAGS) -c $< -o $*.o + +obj/fonts4x6.o: src/fonts4x6.c + $(GCC) $(CFLAGS) -c $< -o $*.o + +$(A2MGR): $(A2MGR_M68KEXECUTABLE) obj/a2mgr.bin.stamp + $(BUILDPRC) $(A2MGR) "A2 Manager" Disk2 $(A2MGR_M68KEXECUTABLE) $(A2MGR_BINS) + +$(A2MGR_M68KEXECUTABLE): $(A2MGR_OBJS) + $(GCC) $(CFLAGS) -o $(A2MGR_M68KEXECUTABLE) $(A2MGR_OBJS) + +obj/a2mgr.bin.stamp: src/a2mgr.rcp + $(PILRC) $^ obj + touch $@ + +obj/a2mgr.o: src/a2mgr.c src/a2mgr_rsc.h + $(GCC) $(CFLAGS) -c $< -o $*.o + diff --git a/icons/ApPalm_13x9_256.bmp b/icons/ApPalm_13x9_256.bmp new file mode 100644 index 0000000000000000000000000000000000000000..a7510e900eab68f25f784b14f2b4f71f801d45d8 GIT binary patch literal 1222 zcmZ?rJ;uTS24+B71IXe9Voo4tWZ(dcPXLma`5+i52$Enpmkgx$GBC_xI0t0>2SdZ; z|3C>K`~N5&4TI4%Fr3o>3o-zf01z&ehVg+kSOUgpVqyZTgYlVx03-n8v#_!v%d@et V0TDu;5eyJ~7Dh%EMvw-eegGxK_qYH6 literal 0 HcmV?d00001 diff --git a/icons/ApPalm_15x9_16grey.bmp b/icons/ApPalm_15x9_16grey.bmp new file mode 100644 index 0000000000000000000000000000000000000000..67a632ce340d68b301c677bade6c722786d6dcaa GIT binary patch literal 190 zcmZ?r-Nyg{Wk5;;i1~q-6NniZSb!u0g9i{_=7V4XARC0eyu28)v$GjmT3Q%-dU_b< z%$dV*?AS4e|Ns9Jh0`D)0Z1jOrKN#rB_#;$;s&7^7$9`A8JJE@4GROQOB56o1FIKI H1d0Oy%Kt=s literal 0 HcmV?d00001 diff --git a/icons/ApPalm_15x9_256.bmp b/icons/ApPalm_15x9_256.bmp new file mode 100644 index 0000000000000000000000000000000000000000..64a665e71dda88cc30ef4744d008813a68f27f95 GIT binary patch literal 1222 zcmZ?rJ;uTS24+B71IXeBVoo4tWZ(dcPXLma`5+i52$Enpmkgx$GBC_xI0t0>2SdZ; z|3C>K`~N5&4TI4%Fr3o>3o2lMav7iu7zHdFz%o!i6B83eA(YPy1jzC%tgOiLY%FX* V1QLO$X9NQTpM{Z;g%PZQ0RTc2_yPa` literal 0 HcmV?d00001 diff --git a/icons/ApPalm_15x9_4grey.bmp b/icons/ApPalm_15x9_4grey.bmp new file mode 100644 index 0000000000000000000000000000000000000000..892912bc6c01415a91922b3e60847b6253f7e376 GIT binary patch literal 190 zcmZ?r-Nyg{Wk5;;i1~q-6NniZSb!u0g9i{_=7V4XARC0eyu28)v$GjmT3Q%-dU_b< z%$dV*?AS4e|Ns9Jh0`D)0Z17GF_2C+HUrbCp%8wepct4BlMf3`1@i?31;KQp7)Txf D;7&xg literal 0 HcmV?d00001 diff --git a/icons/ApPalm_15x9_B&W.bmp b/icons/ApPalm_15x9_B&W.bmp new file mode 100644 index 0000000000000000000000000000000000000000..48115b6841771df3b18bb7aa3a56c7e3ee6f41de GIT binary patch literal 98 zcmZ?rO=5rmJ0PV2#QZ?a3B-&*2m&fVe3=h|nSg8%27&+o|1A6@vf( literal 0 HcmV?d00001 diff --git a/icons/ApPalm_32x22_16grey.bmp b/icons/ApPalm_32x22_16grey.bmp new file mode 100644 index 0000000000000000000000000000000000000000..c9a9dea6dd1d48ca8dd221ef31c92d06b8d4d55d GIT binary patch literal 470 zcmZ?ry~fA@24z4}1BexXSPY068CZZM149B({xTl~3jp~b?B(Ufke!{)(9+Vv(9_ey zFlWvjhGWN$G5r7kpD3J$9V98Ch$ks2p$GuEN@_?d(D^PvfFzv)1K95=_F7)W#KeA&V~Y=#-C+2OmWD?LCi6Xpgb=Rd zOT+0Rz=_$BabPIyI0KIkcOk0@*) zwaPgbnm5#V=auPS!BXSBSEjwJy#LiOtjaa;JdFpIox!dNi`Jqy#e739iFvS@onomE U#au$3z^=4-%2cTm7oHRHH@~ literal 0 HcmV?d00001 diff --git a/icons/ApPalm_32x22_4grey.bmp b/icons/ApPalm_32x22_4grey.bmp new file mode 100644 index 0000000000000000000000000000000000000000..98e2edf27e75d661ac5e28f2af93e37fdbb4c6c1 GIT binary patch literal 470 zcmZ?ry~fA@24z4}1BexXSPY068CZZM149B({xBZ|3jp~b?B(Ufke!{)(9+Vv(9_ey zFlWvjhGWN$G5r7kpD3J$9V8p0h$kBxqX+=G#%4$=(D|W2fFzv?=%0kVnEuav*hgWdHv^!TA4w0}vlzM$msi>OlDXe*mFZNVWg~ literal 0 HcmV?d00001 diff --git a/icons/ApPalm_32x22_original.bmp b/icons/ApPalm_32x22_original.bmp new file mode 100644 index 0000000000000000000000000000000000000000..19a771eafac15e73ceb0c520d930b8c396c7c546 GIT binary patch literal 2166 zcmd6lO-mb56o$uL{75vdMp0`mwiqc$i4p{sRQ9 zw2LZ&OS5v}M(8R(!F_)~H~tEJ#sjkmZZf@#4)-3;J#+7K-gEBlH&%Vx-514%na#`) zvqY=IYFZ!vAC}9!3t(=voBwCD85=T`OA06V{rXXPbR%e928K^@n)IxyEYb0gRd&82 zc3Ae*4kU8^?%mSHA=0TzQQNzTVEDjEflmp(wuG<6Qc^_sU1N2&-e{Kf%JImDIlVOF1AW2r*;l;H5~yb^v>@;eQO z?4+Pei5w-6i-)9y-=02%U-RoPRiGI-ODyk73183bpd3C!_;eoqQA-UUk(25oQY1ayI%7%}HwBTHowC0C z@Ft#9qo2Q`AAWp&{Y9+5VXz0d!yoJkMOsM*AN{XB%zIAZl4%QAn67?V!uJd>I0y>( u%9eC6oNdFJ|Sx|KOwwdI$qotf=u}Eo9i)5t`jevXD z?BL@XaFdVHxm$z7b55>skgxUoT(R4nTAbg!kXLzM|1K}hAsx5C3mb$2C4e<`H?squ jfz}A+ZO>-{DcLMLlf^r)aYO+Tmu?xs-VBaN3Yv5Rv+e!Y literal 0 HcmV?d00001 diff --git a/icons/ApPalm_32x32_4grey.bmp b/icons/ApPalm_32x32_4grey.bmp new file mode 100644 index 0000000000000000000000000000000000000000..539292d7aa51bdd3a47ffa2b153f84789e48f721 GIT binary patch literal 630 zcmbVJK@NZ*3SDvS1ITSl-}CnWG_ihP(FL}50s$&Oxc~qF literal 0 HcmV?d00001 diff --git a/icons/ApPalm_32x32_B&W.bmp b/icons/ApPalm_32x32_B&W.bmp new file mode 100644 index 0000000000000000000000000000000000000000..867b2852f3fcab443483c1d398352cac9a9befd9 GIT binary patch literal 190 zcmYk#F%CdL6a>&gp-^n0m8{Y!Y@&B25(jW2XW<5PBx2065HeXAdnL2sSUA$CB$Xjh IA2&I81H{ckCjbBd literal 0 HcmV?d00001 diff --git a/palmapple/6502.c b/palmapple/6502.c new file mode 100644 index 0000000..83423ea --- /dev/null +++ b/palmapple/6502.c @@ -0,0 +1,1960 @@ +#include "6502.h" +#include "iou.h" +#include "memory.h" + +extern READBYTE ReadFunction[256]; +extern WRITEBYTE WriteFunction[256]; +extern UInt8 *AppleMemory; +extern UInt8 *AuxMemory; +extern UInt8 *AppleROM; +extern UInt16 *IOUState; + +extern UInt16 IOUSoftSwitch[2]; + +#define LOW_BYTE 1 +#define HIGH_BYTE 0 + +// Macro for the Memory Read Operation + +#define INSTRUCTION_FETCH(opcode) opcode = _AppleMemory[PC.PC]; asm("and.l #0xFFFF, %2\n\tmove.b 2(%1, %2.l), %0\n\tlsl.w #0x08, %0\n\tmove.b 1(%1, %2.l), %0" : : "d" (PreFetch), "a" (_AppleMemory), "d" (PC.PC)); PC.PC++; + +#define MEMORY_READ(value, address) TempFuncRead = ReadFunction[address.Byte[HIGH_BYTE]]; if (TempFuncRead) { Address.PC = address.PC; value = TempFuncRead(); } else { value = _AppleMemory[address.PC]; } + +#define MEMORY_WRITE(value, address) TempFuncWrite = WriteFunction[address.Byte[HIGH_BYTE]]; if (TempFuncWrite) { Address.PC = address.PC; TempFuncWrite(value); } else _AppleMemory[address.PC] = value; + +#define ZERO_PAGE_READ(addr) _AppleMemory[addr.Byte[LOW_BYTE]] +#define ZERO_PAGE_WRITE(addr, data) _AppleMemory[addr.Byte[LOW_BYTE]] = data; + +#define PUSH(X) _AppleMemory[Stack.PC] = X; Stack.Byte[LOW_BYTE]--; +#define POP(X) Stack.Byte[LOW_BYTE]++; X = _AppleMemory[Stack.PC]; + +// #define eaimm(value) INSTRUCTION_FETCH(value); +#define eaimm(value) PC.PC++; value = PreFetch & 0xFF; + +// #define eazpx(value) INSTRUCTION_FETCH(value); value = value + X; +#define eazpx(value) PC.PC++; value = PreFetch & 0xFF + X; + +/* #define mr_eazpx(value) eazpx(TempByte); value = _AppleMemory[TempByte]; */ +/* #define mw_eazpx(value) eazpx(TempByte); _AppleMemory[TempByte] = value; */ +#define mr_eazpx(value) PC.PC++; TempByte = (PreFetch & 0xFF) + X; value = _AppleMemory[TempByte]; +#define mw_eazpx(value) PC.PC++; TempByte = (PreFetch & 0xFF) + X; _AppleMemory[TempByte] = value; + +// #define eazpy(value) INSTRUCTION_FETCH(TempByte); value = value + Y; +#define eazpy(value) PC.PC++; value = PreFetch & 0xFF + Y; + +/* #define mr_eazpy(value) eazpy(TempByte); value = _AppleMemory[TempByte]; */ +/* #define mw_eazpy(value) eazpy(TempByte); _AppleMemory[TempByte] = value; */ +#define mr_eazpy(value) PC.PC++; TempByte = PreFetch & 0xFF + Y; value = _AppleMemory[TempByte]; +#define mw_eazpy(value) PC.PC++; TempByte = PreFetch & 0xFF + Y; _AppleMemory[TempByte] = value; + +// #define eaabs(value) INSTRUCTION_FETCH(value.Byte[LOW_BYTE]); INSTRUCTION_FETCH(value.Byte[HIGH_BYTE]); + +#define eaabs(value) PC.PC+=2; value.PC = PreFetch; +#define mr_eaabs(value) PC.PC+=2; TempWord.PC = PreFetch; MEMORY_READ(value, TempWord); +#define mw_eaabs(value) PC.PC+=2; TempWord.PC = PreFetch; MEMORY_WRITE(value, TempWord); + +#define eaabsind() INSTRUCTION_FETCH(TempWord.Byte[LOW_BYTE]); \ +INSTRUCTION_FETCH(TempWord.Byte[HIGH_BYTE]); MEMORY_READ(PC.Byte[LOW_BYTE], TempWord); \ +TempWord.PC += 1; MEMORY_READ(PC.Byte[HIGH_BYTE], TempWord); + +#define eaabsx(value) eaabs(value); value.PC += X; +#define mr_eaabsx(value) eaabsx(TempWord); MEMORY_READ(value, TempWord); +#define mw_eaabsx(value) eaabsx(TempWord); MEMORY_WRITE(value, TempWord); + +#define eaabsy(value) eaabs(value); value.PC += Y; +#define mr_eaabsy(value) eaabsy(TempWord); MEMORY_READ(value, TempWord); +#define mw_eaabsy(value) eaabsy(TempWord); MEMORY_WRITE(value, TempWord); + +#define earel(value) INSTRUCTION_FETCH(value.Byte[LOW_BYTE]); asm("ext.w %0" : : "d" (value.PC)); + +#define eazp(value) PC.PC++; TempByte = PreFetch & 0xFF; value = _AppleMemory[TempByte]; +#define mw_eazp(value) PC.PC++; TempByte = PreFetch & 0xFF; _AppleMemory[TempByte] = value; + +#define eazpxind(value) eazpx(TempByte); value.Byte[LOW_BYTE] = _AppleMemory[TempByte]; \ +value.Byte[HIGH_BYTE] = _AppleMemory[TempByte + 1]; + +#define mr_eazpxind(value) eazpxind(TempWord); MEMORY_READ(value, TempWord); +#define mw_eazpxind(value) eazpxind(TempWord); MEMORY_WRITE(value, TempWord); + +#define eazpindy(value) eaimm(TempByte); value.Byte[LOW_BYTE] = _AppleMemory[TempByte]; \ +value.Byte[HIGH_BYTE] = _AppleMemory[TempByte + 1]; value.PC += Y; + +#define mr_eazpindy(value) eazpindy(TempWord); MEMORY_READ(value, TempWord); +#define mw_eazpindy(value) eazpindy(TempWord); MEMORY_WRITE(value, TempWord); + +/* MC6502 Instruction New Address Mode */ +#define eazpind() PC.PC++; TempByte = PreFetch & 0xFF; TempWord.Byte[LOW_BYTE] = _AppleMemory[TempByte]; TempWord.Byte[HIGH_BYTE] = _AppleMemory[TempByte + 1]; +#define mr_eazpind(value) eazpind(); value = _AppleMemory[TempWord.PC]; +#define mw_eazpind(value) eazpind(); _AppleMemory[TempWord.PC] = value; + +#define eaabsxind() eaabs(TempWord); TempWord.PC += X; PC.Byte[LOW_BYTE] = _AppleMemory[TempWord.PC]; PC.Byte[HIGH_BYTE] = _AppleMemory[TempWord.PC + 1]; + +union PCStruct PC; +union PCStruct Stack; +union PCStruct Address; +UInt8 X, Y, _A, Decimal; +Char buf[50]; +UInt16 Status; +BOOL LOOP, QUIT; +UInt32 Start, End; +UInt16 Count, Count1; + +extern UInt16 refNum; +extern char *AppleFontBitmap; +extern UInt8 LastKey; + +UInt8 *AppleFont; +UInt8 *pointer; + +UInt16 ScanlineOffsetTable[192]; +UInt16 ScanlineAddressTable[192]; +UInt16 ScanlineAddressTableH[192]; +UInt16 AppleClock, DiskOffset =0; +extern UInt16 LastAppleClock; +extern UInt16 motor_on; + +void SetupVideo(void) { + WinHandle onScreen; + UInt32 depth = 1; + Boolean colorMode = true; + BitmapType *scanline; + +#ifdef SONY + HRWinScreenMode(refNum, winScreenModeSet, 0, 0, &depth, &colorMode); +#else + WinScreenMode(winScreenModeSet, 0, 0, &depth, &colorMode); +#endif + + onScreen = WinGetDisplayWindow(); + scanline = WinGetBitmap(onScreen); + pointer = (UInt8*) BmpGetBits(scanline); + +#ifdef SONY + pointer += 160 * 12; +#else + pointer += 20 * 20; +#endif + + { + MemHandle handle; + UInt16 count; + + handle = MemHandleNew(0x100 * 0x08); + AppleFont = MemHandleLock(handle); + + MemMove(AppleFont, AppleFontBitmap, 0x40 * 0x08); + MemMove(AppleFont + 0x40 * 0x08, AppleFontBitmap, 0x40 * 0x08); + MemMove(AppleFont + 0x40 * 0x08 * 2, AppleFontBitmap, 0x40 * 0x08); + MemMove(AppleFont + 0x40 * 0x08 * 3, AppleFontBitmap, 0x20 * 0x08); + MemMove(AppleFont + 0x40 * 0x08 * 3 + 0x20 * 0x08, AppleFontBitmap + 0x40 * 0x08, 0x20 * 0x08); + for (count = 0x80 * 0x08; count < (0x100 * 0x08) - 1; count++) AppleFont[count] = ~AppleFont[count]; + } + + { + UInt16 i; + + for (i = 0;i < 192;i++) { + ScanlineOffsetTable[i] = (i & 7) * 0x400 + ((i >> 3) & 7) * 0x80 + (i >> 6) * 0x28; + } + + for (i = 0;i < 192;i++) { + ScanlineAddressTable[i] = ScanlineOffsetTable[i & ~7] + 0x400; + ScanlineAddressTableH[i] = ScanlineOffsetTable[i] + 0x2000; + } + } + +} + +void init_6502() { + Stack.PC = 0x01FF; + _A = 0; X = 0; Y = 0; + PC.Byte[LOW_BYTE] = AppleMemory[0x0000FFFC]; + PC.Byte[HIGH_BYTE] = AppleMemory[0x0000FFFD]; + LOOP = 1; QUIT = 1; + Count = 0; Count1 = 0; + Decimal = 0; + AppleClock = 0; + SetupVideo(); +} + +void run_6502() { + + register UInt8 Opcode; + register READBYTE TempFuncRead; + register WRITEBYTE TempFuncWrite; + register UInt8 *_AppleMemory; + register union PCStruct TempWord; + register UInt8 TempByte; + register UInt8 MemValue; + register UInt16 PreFetch asm ("d4"); + register Int16 hori, vert; + register UInt16 fps, scanaddr, chary; + register UInt8 *_pointer; + +#ifdef SONY + hori = 191; vert = 39; fps = 0; chary = 7; + _pointer = pointer + 192 * 40; + if (IOUSoftSwitch[0] & SS_HIRES) + scanaddr = ScanlineAddressTableH[hori] + 39; + else + scanaddr = ScanlineAddressTable[hori] + 39; +#else + hori = 119; vert = 19; fps = 0; chary = 7; + _pointer = pointer + 120 * 20; + if (IOUSoftSwitch[0] & SS_HIRES) + scanaddr = ScanlineAddressTableH[hori] + 19; + else + scanaddr = ScanlineAddressTable[hori] + 19; +#endif + + _AppleMemory = AppleMemory; + + run_again: + +#ifdef DEBUG + if (!LOOP) HostTraceOutputT(sysErrorClass, "PC : %X\n", PC.PC); +#endif + + INSTRUCTION_FETCH(Opcode); + +#ifdef DEBUG + if (!LOOP) HostTraceOutputT(sysErrorClass, "O : %X A : %X X : %X Y : %X\n", Opcode, _A, X, Y); +#endif + + switch (Opcode) { + case 0x69: /* ADC #imm */ + Status &= 0xFFEF; if (Status & 0x01) Status |= 0x10; + Status |= 0x04; + PC.PC++; + asm("move.b %0, %1\n\tbne .adc_69_decimal" : : "m" (Decimal), "d" (Decimal)); + asm("move.w %0, %%ccr\n\taddx.b %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : + : "m" (Status), "d" (_A), "d" (PreFetch), "m" (_A) + ); + asm("bra .adc_69_finish"); + asm(".adc_69_decimal:"); + asm("move.w %0, %%ccr\n\tabcd %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : + : "m" (Status), "d" (_A), "d" (PreFetch), "m" (_A) + ); + asm(".adc_69_finish:"); + AppleClock+=2; + break; + case 0x6D: /* ADC abs */ + Status &= 0xFFEF; if (Status & 0x01) Status |= 0x10; + Status |= 0x04; + mr_eaabs(MemValue); + asm("move.b %0, %1\n\tbne .adc_6d_decimal" : : "m" (Decimal), "d" (Decimal)); + asm("move.w %0, %%ccr\n\taddx.b %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : + : "m" (Status), "d" (_A), "d" (MemValue), "m" (_A) + ); + asm("bra .adc_6d_finish"); + asm(".adc_6d_decimal:"); + asm("move.w %0, %%ccr\n\tabcd %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : + : "m" (Status), "d" (_A), "d" (MemValue), "m" (_A) + ); + asm(".adc_6d_finish:"); + AppleClock+=4; + break; + case 0x65: /* ADC zp */ + Status &= 0xFFEF; if (Status & 0x01) Status |= 0x10; + Status |= 0x04; + eazp(MemValue); + asm("move.b %0, %1\n\tbne .adc_65_decimal" : : "m" (Decimal), "d" (Decimal)); + asm("move.w %0, %%ccr\n\taddx.b %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : + : "m" (Status), "d" (_A), "d" (MemValue), "m" (_A) + ); + asm("bra .adc_65_finish"); + asm(".adc_65_decimal:"); + asm("move.w %0, %%ccr\n\tabcd %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : + : "m" (Status), "d" (_A), "d" (MemValue), "m" (_A) + ); + asm(".adc_65_finish:"); + AppleClock+=3; + break; + case 0x61: /* ADC (zp, X) */ + Status &= 0xFFEF; if (Status & 0x01) Status |= 0x10; + Status |= 0x04; + mr_eazpxind(MemValue); + asm("move.b %0, %1\n\tbne .adc_61_decimal" : : "m" (Decimal), "d" (Decimal)); + asm("move.w %0, %%ccr\n\taddx.b %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : + : "m" (Status), "d" (_A), "d" (MemValue), "m" (_A) + ); + asm("bra .adc_61_finish"); + asm(".adc_61_decimal:"); + asm("move.w %0, %%ccr\n\tabcd %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : + : "m" (Status), "d" (_A), "d" (MemValue), "m" (_A) + ); + asm(".adc_61_finish:"); + AppleClock+=6; + break; + case 0x71: /* ADC (zp), Y */ + Status &= 0xFFEF; if (Status & 0x01) Status |= 0x10; + Status |= 0x04; + mr_eazpindy(MemValue); + asm("move.b %0, %1\n\tbne .adc_71_decimal" : : "m" (Decimal), "d" (Decimal)); + asm("move.w %0, %%ccr\n\taddx.b %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : + : "m" (Status), "d" (_A), "d" (MemValue), "m" (_A) + ); + asm("bra .adc_71_finish"); + asm(".adc_71_decimal:"); + asm("move.w %0, %%ccr\n\tabcd %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : + : "m" (Status), "d" (_A), "d" (MemValue), "m" (_A) + ); + asm(".adc_71_finish:"); + AppleClock+=5; + break; + case 0x75: /* ADC zp, X */ + Status &= 0xFFEF; if (Status & 0x01) Status |= 0x10; + Status |= 0x04; + mr_eazpx(MemValue); + asm("move.b %0, %1\n\tbne .adc_75_decimal" : : "m" (Decimal), "d" (Decimal)); + asm("move.w %0, %%ccr\n\taddx.b %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : + : "m" (Status), "d" (_A), "d" (MemValue), "m" (_A) + ); + asm("bra .adc_75_finish"); + asm(".adc_75_decimal:"); + asm("move.w %0, %%ccr\n\tabcd %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : + : "m" (Status), "d" (_A), "d" (MemValue), "m" (_A) + ); + asm(".adc_75_finish:"); + AppleClock+=4; + break; + case 0x7D: /* ADC abs, X */ + Status &= 0xFFEF; if (Status & 0x01) Status |= 0x10; + Status |= 0x04; + mr_eaabsx(MemValue); + asm("move.b %0, %1\n\tbne .adc_7d_decimal" : : "m" (Decimal), "d" (Decimal)); + asm("move.w %0, %%ccr\n\taddx.b %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : + : "m" (Status), "d" (_A), "d" (MemValue), "m" (_A) + ); + asm("bra .adc_7d_finish"); + asm(".adc_7d_decimal:"); + asm("move.w %0, %%ccr\n\tabcd %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : + : "m" (Status), "d" (_A), "d" (MemValue), "m" (_A) + ); + asm(".adc_7d_finish:"); + AppleClock+=4; + break; + case 0x79: /* ADC abs, Y */ + Status &= 0xFFEF; if (Status & 0x01) Status |= 0x10; + Status |= 0x04; + mr_eaabsy(MemValue); + asm("move.b %0, %1\n\tbne .adc_79_decimal" : : "m" (Decimal), "d" (Decimal)); + asm("move.w %0, %%ccr\n\taddx.b %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : + : "m" (Status), "d" (_A), "d" (MemValue), "m" (_A) + ); + asm("bra .adc_79_finish"); + asm(".adc_79_decimal:"); + asm("move.w %0, %%ccr\n\tabcd %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : + : "m" (Status), "d" (_A), "d" (MemValue), "m" (_A) + ); + asm(".adc_79_finish:"); + AppleClock+=4; + break; + case 0x29: /* AND #imm */ + // eaimm(MemValue); + PC.PC++; + asm("and.b %2, %1\n\tmove.w %%sr, %3\n\tmove %0, %4\n\tandi.w #0x000C, %3\n\tandi.w #0xFFF3, %4\n\tor.b %3, %4\n\tmove.w %4, %0" + : "=m" (Status) + : "m" (_A), "d" (PreFetch), "d" (Status), "d" (MemValue) + ); + AppleClock+=2; + break; + case 0x2D: /* AND abs */ + mr_eaabs(MemValue); + asm("and.b %2, %1\n\tmove.w %%sr, %3\n\tmove %0, %4\n\tandi.w #0x000C, %3\n\tandi.w #0xFFF3, %4\n\tor.b %3, %4\n\tmove.w %4, %0" + : "=m" (Status) + : "m" (_A), "d" (MemValue), "d" (Status), "d" (MemValue) + ); + AppleClock+=4; + break; + case 0x25: /* AND zp */ + eazp(MemValue); + asm("and.b %2, %1\n\tmove.w %%sr, %3\n\tmove %0, %4\n\tandi.w #0x000C, %3\n\tandi.w #0xFFF3, %4\n\tor.b %3, %4\n\tmove.w %4, %0" + : "=m" (Status) + : "m" (_A), "d" (MemValue), "d" (Status), "d" (MemValue) + ); + AppleClock+=3; + break; + case 0x21: /* AND (zp, X) */ + mr_eazpxind(MemValue); + asm("and.b %2, %1\n\tmove.w %%sr, %3\n\tmove %0, %4\n\tandi.w #0x000C, %3\n\tandi.w #0xFFF3, %4\n\tor.b %3, %4\n\tmove.w %4, %0" + : "=m" (Status) + : "m" (_A), "d" (MemValue), "d" (Status), "d" (MemValue) + ); + AppleClock+=6; + break; + case 0x31: /* AND (zp), Y */ + mr_eazpindy(MemValue); + asm("and.b %2, %1\n\tmove.w %%sr, %3\n\tmove %0, %4\n\tandi.w #0x000C, %3\n\tandi.w #0xFFF3, %4\n\tor.b %3, %4\n\tmove.w %4, %0" + : "=m" (Status) + : "m" (_A), "d" (MemValue), "d" (Status), "d" (MemValue) + ); + AppleClock+=5; + break; + case 0x35: /* AND zp, X */ + mr_eazpx(MemValue); + asm("and.b %2, %1\n\tmove.w %%sr, %3\n\tmove %0, %4\n\tandi.w #0x000C, %3\n\tandi.w #0xFFF3, %4\n\tor.b %3, %4\n\tmove.w %4, %0" + : "=m" (Status) + : "m" (_A), "d" (MemValue), "d" (Status), "d" (MemValue) + ); + AppleClock+=4; + break; + case 0x3D: /* AND abs, X */ + mr_eaabsx(MemValue); + asm("and.b %2, %1\n\tmove.w %%sr, %3\n\tmove %0, %4\n\tandi.w #0x000C, %3\n\tandi.w #0xFFF3, %4\n\tor.b %3, %4\n\tmove.w %4, %0" + : "=m" (Status) + : "m" (_A), "d" (MemValue), "d" (Status), "d" (MemValue) + ); + break; + case 0x39: /* AND abs, Y */ + mr_eaabsy(MemValue); + asm("and.b %2, %1\n\tmove.w %%sr, %3\n\tmove %0, %4\n\tandi.w #0x000C, %3\n\tandi.w #0xFFF3, %4\n\tor.b %3, %4\n\tmove.w %4, %0" + : "=m" (Status) + : "m" (_A), "d" (MemValue), "d" (Status), "d" (MemValue) + ); + AppleClock+=4; + break; + + case 0x0E: /* ASL abs */ + mr_eaabs(MemValue); + + asm("lsl.b #1, %0\n\tmove.w %%sr, %1\n\tandi.w #0x0002, %2\n\tor.w %1, %2" + : + : "d" (MemValue), "d" (Status), "m" (Status) + ); + + MEMORY_WRITE(MemValue, TempWord); + AppleClock+=6; + break; + case 0x06: /* ASL zp */ + eazp(MemValue); + + asm("lsl.b #1, %0\n\tmove.w %%sr, %1\n\tandi.w #0x0002, %2\n\tor.w %1, %2" + : + : "d" (MemValue), "d" (Status), "m" (Status) + ); + + _AppleMemory[TempByte] = MemValue; + AppleClock+=5; + break; + case 0x0A: /* ASL acc */ + asm("lsl.b #1, %0\n\tmove.w %%sr, %1\n\tandi.w #0x0002, %2\n\tor.w %1, %2\n\tmove.b %0, %3" + : + : "d" (_A), "d" (Status), "m" (Status), "m" (_A) + ); + AppleClock+=2; + break; + case 0x16: /* ASL zp, X */ + mr_eazpx(MemValue); + + asm("lsl.b #1, %0\n\tmove.w %%sr, %1\n\tandi.w #0x0002, %2\n\tor.w %1, %2" + : + : "d" (MemValue), "d" (Status), "m" (Status) + ); + + _AppleMemory[TempByte] = MemValue; + AppleClock+=6; + break; + case 0x1E: /* ASL abs, X */ + mr_eaabsx(MemValue); + + asm("lsl.b #1, %0\n\tmove.w %%sr, %1\n\tandi.w #0x0002, %2\n\tor.w %1, %2" + : + : "d" (MemValue), "d" (Status), "m" (Status) + ); + + MEMORY_WRITE(MemValue, TempWord); + AppleClock+=7; + break; + + case 0x90: /* BCC rr */ + AppleClock+=2; + PC.PC++; + asm("move %0, %%ccr" : "=m" (Status)); + asm("bcs .bcc_leave"); + asm("ext.w %0" : : "d" (PreFetch)); + PC.PC += PreFetch; + AppleClock++; + asm(".bcc_leave:"); + break; + case 0xB0: /* BCS rr */ + PC.PC++; + AppleClock+=2; + asm("move %0, %%ccr" : "=m" (Status)); + asm("bcc .bcs_leave"); + asm("ext.w %0" : : "d" (PreFetch)); + PC.PC += PreFetch; + AppleClock++; + asm(".bcs_leave:"); + break; + case 0xF0: /* BEQ rr */ + PC.PC++; + AppleClock+=2; + asm("move %0, %%ccr" : "=m" (Status)); + asm("bne .beq_leave"); + asm("ext.w %0" : : "d" (PreFetch)); + PC.PC += PreFetch; + AppleClock++; + asm(".beq_leave:"); + break; + + case 0x2C: /* BIT abs */ + mr_eaabs(MemValue); + asm("andi.w #0xFFF1, %0\n\tand.b %2, %1\n\tmove.w %%sr, %3\n\tandi.w #0x04, %3\n\tor.w %3, %0\n\tclr.w %3\n\tmove.b %2, %3\n\tandi.w #0x0080, %3\n\tlsr.w #4, %3\n\tor.w %3, %0\n\tclr.w %3\n\tmove.b %2, %3\n\tandi.w #0x0040, %3\n\tlsr.w #5, %3\n\tor.w %3, %0" + : + : "m" (Status), "d" (_A), "d" (MemValue), "d" (Status) + ); + AppleClock+=4; + break; + case 0x24: /* BIT zp */ + eazp(MemValue); + asm("andi.w #0xFFF1, %0\n\tand.b %2, %1\n\tmove.w %%sr, %3\n\tandi.w #0x04, %3\n\tor.w %3, %0\n\tclr.w %3\n\tmove.b %2, %3\n\tandi.w #0x0080, %3\n\tlsr.w #4, %3\n\tor.w %3, %0\n\tclr.w %3\n\tmove.b %2, %3\n\tandi.w #0x0040, %3\n\tlsr.w #5, %3\n\tor.w %3, %0" + : + : "m" (Status), "d" (_A), "d" (MemValue), "d" (Status) + ); + AppleClock+=3; + break; + + case 0x30: /* BMI rr */ + PC.PC++; + AppleClock+=2; + asm("move %0, %%ccr" : "=m" (Status)); + asm("bpl .bmi_leave"); + asm("ext.w %0" : : "d" (PreFetch)); + PC.PC += PreFetch; + AppleClock++; + asm(".bmi_leave:"); + break; + case 0xD0: /* BNE rr */ + PC.PC++; + AppleClock+=2; + asm("move %0, %%ccr" : "=m" (Status)); + asm("beq .bne_leave"); + asm("ext.w %0" : : "d" (PreFetch)); + PC.PC += PreFetch; + AppleClock++; + asm(".bne_leave:"); + break; + case 0x10: /* BPL rr */ + PC.PC++; + AppleClock+=2; + asm("move %0, %%ccr" : "=m" (Status)); + asm("bmi .bpl_leave"); + asm("ext.w %0" : : "d" (PreFetch)); + PC.PC += PreFetch; + AppleClock++; + asm(".bpl_leave:"); + break; + + case 0x00: /* BRK */ + break; + + case 0x50: /* BVC rr */ + PC.PC++; + AppleClock+=2; + asm("move %0, %%ccr" : "=m" (Status)); + asm("bvs .bvc_leave"); + asm("ext.w %0" : : "d" (PreFetch)); + PC.PC += PreFetch; + AppleClock++; + asm(".bvc_leave:"); + break; + case 0x70: /* BVS rr */ + PC.PC++; + AppleClock+=2; + asm("move %0, %%ccr" : "=m" (Status)); + asm("bvc .bvs_leave"); + asm("ext.w %0" : : "d" (PreFetch)); + PC.PC += PreFetch; + AppleClock++; + asm(".bvs_leave:"); + break; + + case 0x18: /* CLC */ + asm("andi.w #0xFFEE, %0" : "=m" (Status)); + AppleClock+=2; + break; + case 0xD8: /* CLD */ + asm("clr.b %0" : : "m" (Decimal)); + AppleClock+=2; + break; + case 0x58: /* CLI */ + AppleClock+=2; + break; + case 0xB8: /* CLV */ + asm("andi.w #0xFFFD, %0" : "=m" (Status)); + AppleClock+=2; + break; + case 0xC9: /* CMP #imm */ + // eaimm(MemValue); + PC.PC++; + asm("neg.b %1\n\tadd.b %1, %0\n\tmove %%sr, %2\n\tandi.w #0xFFF2, %3\n\tandi.w #0x000D, %2\n\tor.w %2, %3\n\tneg.b %1" + : + : "d" (_A), "d" (PreFetch), "d" (Status), "m" (Status) + ); + if (_A >= (PreFetch & 0xFF)) Status |= 0x01; else Status &= 0xFFFE; + AppleClock+=2; + break; + case 0xCD: /* CMP abs */ + mr_eaabs(MemValue); + asm("neg.b %1\n\tadd.b %1, %0\n\tmove %%sr, %2\n\tandi.w #0xFFF2, %3\n\tandi.w #0x000D, %2\n\tor.w %2, %3\n\tneg.b %1" + : + : "d" (_A), "d" (MemValue), "d" (Status), "m" (Status) + ); + if (_A >= MemValue) Status |= 0x01; else Status &= 0xFFFE; + AppleClock+=4; + break; + case 0xC5: /* CMP zp */ + eazp(MemValue); + asm("neg.b %1\n\tadd.b %1, %0\n\tmove %%sr, %2\n\tandi.w #0xFFF2, %3\n\tandi.w #0x000D, %2\n\tor.w %2, %3\n\tneg.b %1" + : + : "d" (_A), "d" (MemValue), "d" (Status), "m" (Status) + ); + if (_A >= MemValue) Status |= 0x01; else Status &= 0xFFFE; + AppleClock+=3; + break; + case 0xC1: /* CMP (zp, X) */ + mr_eazpxind(MemValue); + asm("neg.b %1\n\tadd.b %1, %0\n\tmove %%sr, %2\n\tandi.w #0xFFF2, %3\n\tandi.w #0x000D, %2\n\tor.w %2, %3\n\tneg.b %1" + : + : "d" (_A), "d" (MemValue), "d" (Status), "m" (Status) + ); + if (_A >= MemValue) Status |= 0x01; else Status &= 0xFFFE; + AppleClock+=6; + break; + case 0xD1: /* CMP (zp), Y */ + mr_eazpindy(MemValue); + asm("neg.b %1\n\tadd.b %1, %0\n\tmove %%sr, %2\n\tandi.w #0xFFF2, %3\n\tandi.w #0x000D, %2\n\tor.w %2, %3\n\tneg.b %1" + : + : "d" (_A), "d" (MemValue), "d" (Status), "m" (Status) + ); + if (_A >= MemValue) Status |= 0x01; else Status &= 0xFFFE; + AppleClock+=5; + break; + case 0xD5: /* CMP zp, X */ + mr_eazpx(MemValue); + asm("neg.b %1\n\tadd.b %1, %0\n\tmove %%sr, %2\n\tandi.w #0xFFF2, %3\n\tandi.w #0x000D, %2\n\tor.w %2, %3\n\tneg.b %1" + : + : "d" (_A), "d" (MemValue), "d" (Status), "m" (Status) + ); + if (_A >= MemValue) Status |= 0x01; else Status &= 0xFFFE; + AppleClock+=4; + break; + case 0xDD: /* CMP abs, X */ + mr_eaabsx(MemValue); + asm("neg.b %1\n\tadd.b %1, %0\n\tmove %%sr, %2\n\tandi.w #0xFFF2, %3\n\tandi.w #0x000D, %2\n\tor.w %2, %3\n\tneg.b %1" + : + : "d" (_A), "d" (MemValue), "d" (Status), "m" (Status) + ); + if (_A >= MemValue) Status |= 0x01; else Status &= 0xFFFE; +/* if (!LOOP) HostTraceOutputT(sysErrorClass, "CMP abs, X : %X %X %X %X\n", TempWord.PC, X, MemValue, _A); */ + AppleClock+=4; + break; + case 0xD9: /* CMP abs, Y */ + mr_eaabsy(MemValue); + asm("neg.b %1\n\tadd.b %1, %0\n\tmove %%sr, %2\n\tandi.w #0xFFF2, %3\n\tandi.w #0x000D, %2\n\tor.w %2, %3\n\tneg.b %1" + : + : "d" (_A), "d" (MemValue), "d" (Status), "m" (Status) + ); + if (_A >= MemValue) Status |= 0x01; else Status &= 0xFFFE; + AppleClock+=4; + break; + + case 0xE0: /* CPX #imm */ + // eaimm(MemValue); + PC.PC++; + asm("neg.b %1\n\tadd.b %1, %0\n\tmove %%sr, %2\n\tandi.w #0xFFF2, %3\n\tandi.w #0x000D, %2\n\tor.w %2, %3\n\tneg.b %1" + : + : "d" (X), "d" (PreFetch), "d" (Status), "m" (Status) + ); + if (X >= (PreFetch & 0xFF)) Status |= 0x01; else Status &= 0xFFFE; + AppleClock+=2; + break; + case 0xEC: /* CPX abs */ + mr_eaabs(MemValue); + asm("neg.b %1\n\tadd.b %1, %0\n\tmove %%sr, %2\n\tandi.w #0xFFF2, %3\n\tandi.w #0x000D, %2\n\tor.w %2, %3\n\tneg.b %1" + : + : "d" (X), "d" (MemValue), "d" (Status), "m" (Status) + ); + if (X >= MemValue) Status |= 0x01; else Status &= 0xFFFE; + AppleClock+=4; + break; + case 0xE4: /* CPX zp */ + eazp(MemValue); + asm("neg.b %1\n\tadd.b %1, %0\n\tmove %%sr, %2\n\tandi.w #0xFFF2, %3\n\tandi.w #0x000D, %2\n\tor.w %2, %3\n\tneg.b %1" + : + : "d" (X), "d" (MemValue), "d" (Status), "m" (Status) + ); + if (X >= MemValue) Status |= 0x01; else Status &= 0xFFFE; + AppleClock+=3; + break; + + case 0xC0: /* CPY #imm */ + // eaimm(MemValue); + PC.PC++; + asm("neg.b %1\n\tadd.b %1, %0\n\tmove %%sr, %2\n\tandi.w #0xFFF2, %3\n\tandi.w #0x000D, %2\n\tor.w %2, %3\n\tneg.b %1" + : + : "d" (Y), "d" (PreFetch), "d" (Status), "m" (Status) + ); + if (Y >= (PreFetch & 0xFF)) Status |= 0x01; else Status &= 0xFFFE; + AppleClock+=2; + break; + case 0xCC: /* CPY abs */ + mr_eaabs(MemValue); + asm("neg.b %1\n\tadd.b %1, %0\n\tmove %%sr, %2\n\tandi.w #0xFFF2, %3\n\tandi.w #0x000D, %2\n\tor.w %2, %3\n\tneg.b %1" + : + : "d" (Y), "d" (MemValue), "d" (Status), "m" (Status) + ); + if (Y >= MemValue) Status |= 0x01; else Status &= 0xFFFE; + AppleClock+=4; + break; + case 0xC4: /* CPY zp */ + eazp(MemValue); + asm("neg.b %1\n\tadd.b %1, %0\n\tmove %%sr, %2\n\tandi.w #0xFFF2, %3\n\tandi.w #0x000D, %2\n\tor.w %2, %3\n\tneg.b %1" + : + : "d" (Y), "d" (MemValue), "d" (Status), "m" (Status) + ); + if (Y >= MemValue) Status |= 0x01; else Status &= 0xFFFE; + AppleClock+=3; + break; + + case 0xCE: /* DEC abs */ + mr_eaabs(MemValue); + asm("addi.b #0xFF, %0\n\tmove %%sr, %1\n\tandi.w #0x000C, %1\n\tandi.w #0xFFF3, %2\n\tor.w %1, %2" + : + : "d" (MemValue), "d" (Status), "m" (Status) + ); + MEMORY_WRITE(MemValue, TempWord); + AppleClock+=6; + break; + case 0xC6: /* DEC zp */ + eazp(MemValue); + asm("addi.b #0xFF, %0\n\tmove %%sr, %1\n\tandi.w #0x000C, %1\n\tandi.w #0xFFF3, %2\n\tor.w %1, %2" + : + : "d" (MemValue), "d" (Status), "m" (Status) + ); + _AppleMemory[TempByte] = MemValue; + AppleClock+=5; + break; + case 0xD6: /* DEC zp, X */ + mr_eazpx(MemValue); + asm("addi.b #0xFF, %0\n\tmove %%sr, %1\n\tandi.w #0x000C, %1\n\tandi.w #0xFFF3, %2\n\tor.w %1, %2" + : + : "d" (MemValue), "d" (Status), "m" (Status) + ); + _AppleMemory[TempByte] = MemValue; + AppleClock+=6; + break; + case 0xDE: /* DEC abs, X */ + mr_eaabsx(MemValue); + asm("addi.b #0xFF, %0\n\tmove %%sr, %1\n\tandi.w #0x000C, %1\n\tandi.w #0xFFF3, %2\n\tor.w %1, %2" + : + : "d" (MemValue), "d" (Status), "m" (Status) + ); + MEMORY_WRITE(MemValue, TempWord); + AppleClock+=7; + break; + case 0xCA: /* DEX */ + asm("addi.b #0xFF, %0\n\tmove %%sr, %1\n\tandi.w #0x000C, %1\n\tandi.w #0xFFF3, %2\n\tor.w %1, %2" + : + : "m" (X), "d" (Status), "m" (Status) + ); + AppleClock+=2; + break; + case 0x88: /* DEY */ + asm("addi.b #0xFF, %0\n\tmove %%sr, %1\n\tandi.w #0x000C, %1\n\tandi.w #0xFFF3, %2\n\tor.w %1, %2" + : + : "m" (Y), "d" (Status), "m" (Status) + ); + AppleClock+=2; + break; + + case 0x49: /* EOR #imm */ + // eaimm(MemValue); + PC.PC++; + asm("eor.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "d" (PreFetch), "m" (_A), "d" (Status), "m" (Status) + ); + AppleClock+=2; + break; + case 0x4D: /* EOR abs */ + mr_eaabs(MemValue); + asm("eor.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "d" (MemValue), "m" (_A), "d" (Status), "m" (Status) + ); + AppleClock+=4; + break; + case 0x45: /* EOR zp */ + eazp(MemValue); + asm("eor.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "d" (MemValue), "m" (_A), "d" (Status), "m" (Status) + ); + AppleClock+=3; + break; + case 0x41: /* EOR (zp, X) */ + mr_eazpxind(MemValue); + asm("eor.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "d" (MemValue), "m" (_A), "d" (Status), "m" (Status) + ); + AppleClock+=6; + break; + case 0x51: /* EOR (zp), Y */ + mr_eazpindy(MemValue); + asm("eor.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "d" (MemValue), "m" (_A), "d" (Status), "m" (Status) + ); + AppleClock+=5; + break; + case 0x55: /* EOR zp, X */ + mr_eazpx(MemValue); + asm("eor.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "d" (MemValue), "m" (_A), "d" (Status), "m" (Status) + ); + AppleClock+=4; + break; + case 0x5D: /* EOR abs, X */ + mr_eaabsx(MemValue); + asm("eor.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "d" (MemValue), "m" (_A), "d" (Status), "m" (Status) + ); + AppleClock+=4; + break; + case 0x59: /* EOR abs, Y */ + mr_eaabsy(MemValue); + asm("eor.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "d" (MemValue), "m" (_A), "d" (Status), "m" (Status) + ); + AppleClock+=4; + break; + + case 0xEE: /* INC abs */ + mr_eaabs(MemValue); + asm("addi.b #0x01, %0\n\tmove %%sr, %1\n\tandi.w #0x000C, %1\n\tandi.w #0xFFF3, %2\n\tor.w %1, %2" + : + : "d" (MemValue), "d" (Status), "m" (Status) + ); + MEMORY_WRITE(MemValue, TempWord); + AppleClock+=6; + break; + case 0xE6: /* INC zp */ + eazp(MemValue); + asm("addi.b #0x01, %0\n\tmove %%sr, %1\n\tandi.w #0x000C, %1\n\tandi.w #0xFFF3, %2\n\tor.w %1, %2" + : + : "d" (MemValue), "d" (Status), "m" (Status) + ); + _AppleMemory[TempByte] = MemValue; + AppleClock+=5; + break; + case 0xF6: /* INC zp, X */ + mr_eazpx(MemValue); + asm("addi.b #0x01, %0\n\tmove %%sr, %1\n\tandi.w #0x000C, %1\n\tandi.w #0xFFF3, %2\n\tor.w %1, %2" + : + : "d" (MemValue), "d" (Status), "m" (Status) + ); + _AppleMemory[TempByte] = MemValue; + AppleClock+=6; + break; + case 0xFE: /* INC abs, X */ + mr_eaabsx(MemValue); + asm("addi.b #0x01, %0\n\tmove %%sr, %1\n\tandi.w #0x000C, %1\n\tandi.w #0xFFF3, %2\n\tor.w %1, %2" + : + : "d" (MemValue), "d" (Status), "m" (Status) + ); + MEMORY_WRITE(MemValue, TempWord); + AppleClock+=7; + break; + case 0xE8: /* INX */ + asm("addi.b #0x01, %0\n\tmove %%sr, %1\n\tandi.w #0x000C, %1\n\tandi.w #0xFFF3, %2\n\tor.w %1, %2" + : + : "m" (X), "d" (Status), "m" (Status) + ); + AppleClock+=2; + break; + case 0xC8: /* INY */ + asm("addi.b #0x01, %0\n\tmove %%sr, %1\n\tandi.w #0x000C, %1\n\tandi.w #0xFFF3, %2\n\tor.w %1, %2" + : + : "m" (Y), "d" (Status), "m" (Status) + ); + AppleClock+=2; + break; + + case 0x4C: /* JMP abs */ + // eaabs(TempWord); + PC.PC = PreFetch; + AppleClock+=3; + break; + case 0x6C: /* JMP (abs) */ + eaabsind(); + AppleClock+=5; + break; + + case 0x20: /* JSR abs */ + // eaabs(TempWord); + PC.PC++; + PUSH(PC.Byte[HIGH_BYTE]); + PUSH(PC.Byte[LOW_BYTE]); + PC.PC = PreFetch; + // PC.PC = TempWord.PC; + AppleClock+=6; + break; + + case 0xA9: /* LDA #imm */ + // eaimm(MemValue); + PC.PC++; + asm("move.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "d" (PreFetch), "m" (_A), "d" (Status), "m" (Status) + ); + AppleClock+=2; + break; + case 0xAD: /* LDA abs */ + mr_eaabs(MemValue); + asm("move.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "d" (MemValue), "m" (_A), "d" (Status), "m" (Status) + ); +/* if (!LOOP) HostTraceOutputT(sysErrorClass, "LDA abs : %X %X\n", TempWord.PC, MemValue); */ + AppleClock+=4; + break; + case 0xA5: /* LDA zp */ + eazp(MemValue); + asm("move.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "d" (MemValue), "m" (_A), "d" (Status), "m" (Status) + ); + AppleClock+=3; + break; + case 0xA1: /* LDA (zp, X) */ + mr_eazpxind(MemValue); + asm("move.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "d" (MemValue), "m" (_A), "d" (Status), "m" (Status) + ); + AppleClock+=6; + break; + case 0xB1: /* LDA (zp), Y */ + mr_eazpindy(MemValue); + asm("move.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "d" (MemValue), "m" (_A), "d" (Status), "m" (Status) + ); +/* if (!LOOP) HostTraceOutputT(sysErrorClass, "LDA (zp), Y : %X %X %X\n", MemValue, TempByte, TempWord.PC); */ + AppleClock+=5; + break; + case 0xB5: /* LDA zp, X */ + mr_eazpx(MemValue); + asm("move.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "d" (MemValue), "m" (_A), "d" (Status), "m" (Status) + ); + AppleClock+=4; + break; + case 0xBD: /* LDA abs, X */ + mr_eaabsx(MemValue); + asm("move.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "d" (MemValue), "m" (_A), "d" (Status), "m" (Status) + ); + AppleClock+=4; +/* if (!LOOP) HostTraceOutputT(sysErrorClass, "LDA abs, X : %X %X %X\n", TempWord.PC, X, PreFetch); */ + break; + case 0xB9: /* LDA abs, Y */ + mr_eaabsy(MemValue); + asm("move.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "d" (MemValue), "m" (_A), "d" (Status), "m" (Status) + ); +/* if (!LOOP) HostTraceOutputT(sysErrorClass, "LDA abs, Y : %X %X\n", TempWord.PC, MemValue); */ + AppleClock+=4; + break; + + case 0xA2: /* LDX #imm */ + // eaimm(MemValue); + PC.PC++; + asm("move.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "d" (PreFetch), "m" (X), "d" (Status), "m" (Status) + ); + AppleClock+=2; + break; + case 0xAE: /* LDX abs */ + mr_eaabs(MemValue); + asm("move.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "d" (MemValue), "m" (X), "d" (Status), "m" (Status) + ); + AppleClock+=4; + break; + case 0xA6: /* LDX zp */ + eazp(MemValue); + asm("move.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "d" (MemValue), "m" (X), "d" (Status), "m" (Status) + ); + AppleClock+=3; + break; + case 0xBE: /* LDX abs, Y */ + mr_eaabsy(MemValue); + asm("move.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "d" (MemValue), "m" (X), "d" (Status), "m" (Status) + ); + AppleClock+=4; + break; + case 0xB6: /* LDX zp, Y */ + mr_eazpy(MemValue); + asm("move.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "d" (MemValue), "m" (X), "d" (Status), "m" (Status) + ); + AppleClock+=4; + break; + + case 0xA0: /* LDY #imm */ + // eaimm(MemValue); + PC.PC++; + asm("move.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "d" (PreFetch), "m" (Y), "d" (Status), "m" (Status) + ); + AppleClock+=2; + break; + case 0xAC: /* LDY abs */ + mr_eaabs(MemValue); + asm("move.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "d" (MemValue), "m" (Y), "d" (Status), "m" (Status) + ); + AppleClock+=4; + break; + case 0xA4: /* LDY zp */ + eazp(MemValue); + asm("move.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "d" (MemValue), "m" (Y), "d" (Status), "m" (Status) + ); + AppleClock+=3; + break; + case 0xB4: /* LDY zp, X */ + mr_eazpx(MemValue); + asm("move.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "d" (MemValue), "m" (Y), "d" (Status), "m" (Status) + ); + AppleClock+=4; + break; + case 0xBC: /* LDY abs, X */ + mr_eaabsx(MemValue); + asm("move.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "d" (MemValue), "m" (Y), "d" (Status), "m" (Status) + ); + AppleClock+=4; + break; + + case 0x4E: /* LSR abs */ + mr_eaabs(MemValue); + + asm("lsr.b #1, %0\n\tmove.w %%sr, %1\n\tandi.w #0x0002, %2\n\tandi.w #0xFFF7, %1\n\tor.w %1, %2" + : + : "d" (MemValue), "d" (Status), "m" (Status) + ); + + MEMORY_WRITE(MemValue, TempWord); + AppleClock+=6; + break; + case 0x46: /* LSR zp */ + eazp(MemValue); + + asm("lsr.b #1, %0\n\tmove.w %%sr, %1\n\tandi.w #0x0002, %2\n\tandi.w #0xFFF7, %1\n\tor.w %1, %2" + : + : "d" (MemValue), "d" (Status), "m" (Status) + ); + + _AppleMemory[TempByte] = MemValue; + AppleClock+=5; + break; + case 0x4A: /* LSR acc */ + asm("lsr.b #1, %0\n\tmove.w %%sr, %1\n\tandi.w #0x0002, %2\n\tandi.w #0xFFF7, %1\n\tor.w %1, %2\n\tmove.b %0, %3" + : + : "d" (_A), "d" (Status), "m" (Status), "m" (_A) + ); + AppleClock+=2; + break; + case 0x56: /* LSR zp, X */ + mr_eazpx(MemValue); + + asm("lsr.b #1, %0\n\tmove.w %%sr, %1\n\tandi.w #0x0002, %2\n\tandi.w #0xFFF7, %1\n\tor.w %1, %2" + : + : "d" (MemValue), "d" (Status), "m" (Status) + ); + + _AppleMemory[TempByte] = MemValue; + AppleClock+=6; + break; + case 0x5E: /* LSR abs, X */ + mr_eaabsx(MemValue); + + asm("lsr.b #1, %0\n\tmove.w %%sr, %1\n\tandi.w #0x0002, %2\n\tandi.w #0xFFF7, %1\n\tor.w %1, %2" + : + : "d" (MemValue), "d" (Status), "m" (Status) + ); + + MEMORY_WRITE(MemValue, TempWord); + AppleClock+=7; + break; + + case 0xEA: /* NOP */ + AppleClock+=2; + break; + + case 0x09: /* ORA #imm */ + // eaimm(MemValue); + PC.PC++; + asm("or.b %2, %1\n\tmove.w %%sr, %3\n\tmove %0, %4\n\tandi.w #0x000C, %3\n\tandi.w #0xFFF3, %4\n\tor.b %3, %4\n\tmove.w %4, %0" + : "=m" (Status) + : "m" (_A), "d" (PreFetch), "d" (Status), "d" (MemValue) + ); + AppleClock+=2; + break; + case 0x0D: /* ORA abs */ + mr_eaabs(MemValue); + asm("or.b %2, %1\n\tmove.w %%sr, %3\n\tmove %0, %4\n\tandi.w #0x000C, %3\n\tandi.w #0xFFF3, %4\n\tor.b %3, %4\n\tmove.w %4, %0" + : "=m" (Status) + : "m" (_A), "d" (MemValue), "d" (Status), "d" (MemValue) + ); + AppleClock+=4; + break; + case 0x05: /* ORA zp */ + eazp(MemValue); + asm("or.b %2, %1\n\tmove.w %%sr, %3\n\tmove %0, %4\n\tandi.w #0x000C, %3\n\tandi.w #0xFFF3, %4\n\tor.b %3, %4\n\tmove.w %4, %0" + : "=m" (Status) + : "m" (_A), "d" (MemValue), "d" (Status), "d" (MemValue) + ); + AppleClock+=3; + break; + case 0x01: /* ORA (zp, X) */ + mr_eazpxind(MemValue); + asm("or.b %2, %1\n\tmove.w %%sr, %3\n\tmove %0, %4\n\tandi.w #0x000C, %3\n\tandi.w #0xFFF3, %4\n\tor.b %3, %4\n\tmove.w %4, %0" + : "=m" (Status) + : "m" (_A), "d" (MemValue), "d" (Status), "d" (MemValue) + ); + AppleClock+=6; + break; + case 0x11: /* ORA (zp), Y */ + mr_eazpindy(MemValue); + asm("or.b %2, %1\n\tmove.w %%sr, %3\n\tmove %0, %4\n\tandi.w #0x000C, %3\n\tandi.w #0xFFF3, %4\n\tor.b %3, %4\n\tmove.w %4, %0" + : "=m" (Status) + : "m" (_A), "d" (MemValue), "d" (Status), "d" (MemValue) + ); + AppleClock+=5; + break; + case 0x15: /* ORA zp, X */ + mr_eazpx(MemValue); + asm("or.b %2, %1\n\tmove.w %%sr, %3\n\tmove %0, %4\n\tandi.w #0x000C, %3\n\tandi.w #0xFFF3, %4\n\tor.b %3, %4\n\tmove.w %4, %0" + : "=m" (Status) + : "m" (_A), "d" (MemValue), "d" (Status), "d" (MemValue) + ); + AppleClock+=4; + break; + case 0x1D: /* ORA abs, X */ + mr_eaabsx(MemValue); + asm("or.b %2, %1\n\tmove.w %%sr, %3\n\tmove %0, %4\n\tandi.w #0x000C, %3\n\tandi.w #0xFFF3, %4\n\tor.b %3, %4\n\tmove.w %4, %0" + : "=m" (Status) + : "m" (_A), "d" (MemValue), "d" (Status), "d" (MemValue) + ); + AppleClock+=4; + break; + case 0x19: /* ORA abs, Y */ + mr_eaabsy(MemValue); + asm("or.b %2, %1\n\tmove.w %%sr, %3\n\tmove %0, %4\n\tandi.w #0x000C, %3\n\tandi.w #0xFFF3, %4\n\tor.b %3, %4\n\tmove.w %4, %0" + : "=m" (Status) + : "m" (_A), "d" (MemValue), "d" (Status), "d" (MemValue) + ); + AppleClock+=4; + break; + + case 0x48: /* PHA */ + PUSH(_A); + AppleClock+=3; + break; + case 0x08: /* PHP */ + asm("clr.w %0" + : + : "d" (MemValue) + ); + /* N Flags */ + asm("move %0, %1\n\tandi.w #0x08, %1\n\tlsl.w #4, %1\n\tor.w %1, %2" + : + : "m" (Status), "d" (Status), "d" (MemValue) + ); + /* V Flags */ + asm("move %0, %1\n\tandi.w #0x02, %1\n\tlsl.w #5, %1\n\tor.w %1, %2" + : + : "m" (Status), "d" (Status), "d" (MemValue) + ); + /* Bit 5 Flags */ + asm("ori.w #0x20, %0" + : + : "d" (MemValue) + ); + /* Z Flags */ + asm("move %0, %1\n\tandi.w #0x04, %1\n\tlsr.w #1, %1\n\tor.w %1, %2" + : + : "m" (Status), "d" (Status), "d" (MemValue) + ); + /* C Flags */ + asm("move %0, %1\n\tandi.w #0x01, %1\n\tor.w %1, %2" + : + : "m" (Status), "d" (Status), "d" (MemValue) + ); + MemValue |= Decimal; + PUSH(MemValue); + AppleClock+=3; + break; + case 0x68: /* PLA */ + POP(_A); + asm("move.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "m" (_A), "d" (_A), "d" (Status), "m" (Status) + ); + AppleClock+=4; + break; + case 0x28: /* PLP */ + POP(MemValue); + asm("clr.w %0" + : + : "m" (Status) + ); + /* N Flags */ + asm("move %2, %1\n\tandi.w #0x80, %1\n\tlsr.w #4, %1\n\tor.w %1, %0" + : + : "m" (Status), "d" (Status), "d" (MemValue) + ); + /* V Flags */ + asm("move %2, %1\n\tandi.w #0x40, %1\n\tlsr.w #5, %1\n\tor.w %1, %0" + : + : "m" (Status), "d" (Status), "d" (MemValue) + ); + /* Z Flags */ + asm("move %2, %1\n\tandi.w #0x02, %1\n\tlsl.w #1, %1\n\tor.w %1, %0" + : + : "m" (Status), "d" (Status), "d" (MemValue) + ); + /* C Flags */ + asm("move %2, %1\n\tandi.w #0x01, %1\n\tor.w %1, %0" + : + : "m" (Status), "d" (Status), "d" (MemValue) + ); + /* D Flags */ + asm("move %2, %1\n\tandi.w #0x08, %1\n\tmove.b %1, %0" + : + : "m" (Decimal), "d" (Status), "d" (MemValue) + ); + AppleClock+=4; + break; + + case 0x2E: /* ROL abs */ + mr_eaabs(MemValue); + Status &= 0xFFEF; if (Status & 0x01) Status |= 0x10; + asm("move.w %2, %%ccr\n\troxl.b #1, %0\n\tmove.w %%sr, %1\n\tandi.w #0x0002, %2\n\tor.w %1, %2" + : + : "d" (MemValue), "d" (Status), "m" (Status) + ); + + MEMORY_WRITE(MemValue, TempWord); + AppleClock+=6; + break; + case 0x26: /* ROL zp */ + eazp(MemValue); + Status &= 0xFFEF; if (Status & 0x01) Status |= 0x10; + asm("move.w %2, %%ccr\n\troxl.b #1, %0\n\tmove.w %%sr, %1\n\tandi.w #0x0002, %2\n\tor.w %1, %2" + : + : "d" (MemValue), "d" (Status), "m" (Status) + ); + + _AppleMemory[TempByte] = MemValue; + AppleClock+=5; + break; + case 0x2A: /* ROL acc */ + Status &= 0xFFEF; if (Status & 0x01) Status |= 0x10; + asm("move.w %2, %%ccr\n\troxl.b #1, %0\n\tmove.w %%sr, %1\n\tandi.w #0x0002, %2\n\tor.w %1, %2\n\tmove.b %0, %3" + : + : "d" (_A), "d" (Status), "m" (Status), "m" (_A) + ); + AppleClock+=2; + break; + case 0x36: /* ROL zp, X */ + mr_eazpx(MemValue); + Status &= 0xFFEF; if (Status & 0x01) Status |= 0x10; + asm("move.w %2, %%ccr\n\troxl.b #1, %0\n\tmove.w %%sr, %1\n\tandi.w #0x0002, %2\n\tor.w %1, %2" + : + : "d" (MemValue), "d" (Status), "m" (Status) + ); + + _AppleMemory[TempByte] = MemValue; + AppleClock+=6; + break; + case 0x3E: /* ROL abs, X */ + mr_eaabsx(MemValue); + Status &= 0xFFEF; if (Status & 0x01) Status |= 0x10; + asm("move.w %2, %%ccr\n\troxl.b #1, %0\n\tmove.w %%sr, %1\n\tandi.w #0x0002, %2\n\tor.w %1, %2" + : + : "d" (MemValue), "d" (Status), "m" (Status) + ); + + MEMORY_WRITE(MemValue, TempWord); + AppleClock+=7; + break; + + case 0x6E: /* ROR abs */ + mr_eaabs(MemValue); + Status &= 0xFFEF; if (Status & 0x01) Status |= 0x10; + asm("move.w %2, %%ccr\n\troxr.b #1, %0\n\tmove.w %%sr, %1\n\tandi.w #0x0002, %2\n\tor.w %1, %2" + : + : "d" (MemValue), "d" (Status), "m" (Status) + ); + + MEMORY_WRITE(MemValue, TempWord); + AppleClock+=6; + break; + case 0x66: /* ROR zp */ + eazp(MemValue); + Status &= 0xFFEF; if (Status & 0x01) Status |= 0x10; + asm("move.w %2, %%ccr\n\troxr.b #1, %0\n\tmove.w %%sr, %1\n\tandi.w #0x0002, %2\n\tor.w %1, %2" + : + : "d" (MemValue), "d" (Status), "m" (Status) + ); + + _AppleMemory[TempByte] = MemValue; + AppleClock+=5; + break; + case 0x6A: /* ROR acc */ + Status &= 0xFFEF; if (Status & 0x01) Status |= 0x10; + asm("move.w %2, %%ccr\n\troxr.b #1, %0\n\tmove.w %%sr, %1\n\tandi.w #0x0002, %2\n\tor.w %1, %2\n\tmove.b %0, %3" + : + : "d" (_A), "d" (Status), "m" (Status), "m" (_A) + ); + AppleClock+=2; + break; + case 0x76: /* ROR zp, X */ + mr_eazpx(MemValue); + Status &= 0xFFEF; if (Status & 0x01) Status |= 0x10; + asm("move.w %2, %%ccr\n\troxr.b #1, %0\n\tmove.w %%sr, %1\n\tandi.w #0x0002, %2\n\tor.w %1, %2" + : + : "d" (MemValue), "d" (Status), "m" (Status) + ); + + _AppleMemory[TempByte] = MemValue; + AppleClock+=6; + break; + case 0x7E: /* ROR abs, X */ + mr_eaabsx(MemValue); + Status &= 0xFFEF; if (Status & 0x01) Status |= 0x10; + asm("move.w %2, %%ccr\n\troxr.b #1, %0\n\tmove.w %%sr, %1\n\tandi.w #0x0002, %2\n\tor.w %1, %2" + : + : "d" (MemValue), "d" (Status), "m" (Status) + ); + + MEMORY_WRITE(MemValue, TempWord); + AppleClock+=7; + break; + + case 0x40: /* RTI */ + POP(MemValue); + asm("clr.w %0" + : + : "m" (Status) + ); + /* N Flags */ + asm("move %2, %1\n\tandi.w #0x80, %1\n\tlsr.w #4, %1\n\tor.w %1, %0" + : + : "m" (Status), "d" (Status), "d" (MemValue) + ); + /* V Flags */ + asm("move %2, %1\n\tandi.w #0x40, %1\n\tlsr.w #5, %1\n\tor.w %1, %0" + : + : "m" (Status), "d" (Status), "d" (MemValue) + ); + /* Z Flags */ + asm("move %2, %1\n\tandi.w #0x02, %1\n\tlsl.w #1, %1\n\tor.w %1, %0" + : + : "m" (Status), "d" (Status), "d" (MemValue) + ); + /* C Flags */ + asm("move %2, %1\n\tandi.w #0x01, %1\n\tor.w %1, %0" + : + : "m" (Status), "d" (Status), "d" (MemValue) + ); + /* D Flags */ + asm("move %2, %1\n\tandi.w #0x08, %1\n\tmove.b %1, %0" + : + : "m" (Decimal), "d" (Status), "d" (MemValue) + ); + POP(PC.Byte[LOW_BYTE]); + POP(PC.Byte[HIGH_BYTE]); + AppleClock+=6; + break; + + case 0x60: /* RTS */ + POP(PC.Byte[LOW_BYTE]); + POP(PC.Byte[HIGH_BYTE]); + PC.PC++; + AppleClock+=6; + break; + + case 0xE9: /* SBC #imm */ + // eaimm(MemValue); + PC.PC++; + if (Status & 0x01) Status &= 0xFFEE; else Status |= 0x0011; + Status |= 0x04; + asm("move.b %0, %1\n\tbne .sbc_e9_decimal" : : "m" (Decimal), "d" (Decimal)); + asm("move.w %0, %%ccr\n\tsubx.b %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : "=m" (Status) + : "d" (_A), "d" (PreFetch), "m" (_A) + ); + asm("bra .sbc_e9_finish"); + asm(".sbc_e9_decimal:"); + asm("move.w %0, %%ccr\n\tsbcd %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : "=m" (Status) + : "d" (_A), "d" (PreFetch), "m" (_A) + ); + asm(".sbc_e9_finish:"); + if (Status & 0x01) Status &= 0xFFEE; else Status |= 0x0011; + AppleClock+=2; + break; + case 0xED: /* SBC abs */ + mr_eaabs(MemValue); + if (Status & 0x01) Status &= 0xFFEE; else Status |= 0x0011; + Status |= 0x04; + asm("move.b %0, %1\n\tbne .sbc_ed_decimal" : : "m" (Decimal), "d" (Decimal)); + asm("move.w %0, %%ccr\n\tsubx.b %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : "=m" (Status) + : "d" (_A), "d" (MemValue), "m" (_A) + ); + asm("bra .sbc_ed_finish"); + asm(".sbc_ed_decimal:"); + asm("move.w %0, %%ccr\n\tsbcd %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : "=m" (Status) + : "d" (_A), "d" (MemValue), "m" (_A) + ); + asm(".sbc_ed_finish:"); + if (Status & 0x01) Status &= 0xFFEE; else Status |= 0x0011; + AppleClock+=4; + break; + case 0xE5: /* SBC zp */ + eazp(MemValue); + if (Status & 0x01) Status &= 0xFFEE; else Status |= 0x0011; + Status |= 0x04; + asm("move.b %0, %1\n\tbne .sbc_e5_decimal" : : "m" (Decimal), "d" (Decimal)); + asm("move.w %0, %%ccr\n\tsubx.b %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : "=m" (Status) + : "d" (_A), "d" (MemValue), "m" (_A) + ); + asm("bra .sbc_e5_finish"); + asm(".sbc_e5_decimal:"); + asm("move.w %0, %%ccr\n\tsbcd %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : "=m" (Status) + : "d" (_A), "d" (MemValue), "m" (_A) + ); + asm(".sbc_e5_finish:"); + if (Status & 0x01) Status &= 0xFFEE; else Status |= 0x0011; + AppleClock+=3; + break; + case 0xE1: /* SBC (zp, X) */ + mr_eazpxind(MemValue); + if (Status & 0x01) Status &= 0xFFEE; else Status |= 0x0011; + Status |= 0x04; + asm("move.b %0, %1\n\tbne .sbc_e1_decimal" : : "m" (Decimal), "d" (Decimal)); + asm("move.w %0, %%ccr\n\tsubx.b %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : "=m" (Status) + : "d" (_A), "d" (MemValue), "m" (_A) + ); + asm("bra .sbc_e1_finish"); + asm(".sbc_e1_decimal:"); + asm("move.w %0, %%ccr\n\tsbcd %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : "=m" (Status) + : "d" (_A), "d" (MemValue), "m" (_A) + ); + asm(".sbc_e1_finish:"); + if (Status & 0x01) Status &= 0xFFEE; else Status |= 0x0011; + AppleClock+=6; + break; + case 0xF1: /* SBC (zp), Y */ + mr_eazpindy(MemValue); + if (Status & 0x01) Status &= 0xFFEE; else Status |= 0x0011; + Status |= 0x04; + asm("move.b %0, %1\n\tbne .sbc_f1_decimal" : : "m" (Decimal), "d" (Decimal)); + asm("move.w %0, %%ccr\n\tsubx.b %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : "=m" (Status) + : "d" (_A), "d" (MemValue), "m" (_A) + ); + asm("bra .sbc_f1_finish"); + asm(".sbc_f1_decimal:"); + asm("move.w %0, %%ccr\n\tsbcd %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : "=m" (Status) + : "d" (_A), "d" (MemValue), "m" (_A) + ); + asm(".sbc_f1_finish:"); + if (Status & 0x01) Status &= 0xFFEE; else Status |= 0x0011; + AppleClock+=5; + break; + case 0xF5: /* SBC zp, X */ + mr_eazpx(MemValue); + if (Status & 0x01) Status &= 0xFFEE; else Status |= 0x0011; + Status |= 0x04; + asm("move.b %0, %1\n\tbne .sbc_f5_decimal" : : "m" (Decimal), "d" (Decimal)); + asm("move.w %0, %%ccr\n\tsubx.b %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : "=m" (Status) + : "d" (_A), "d" (MemValue), "m" (_A) + ); + asm("bra .sbc_f5_finish"); + asm(".sbc_f5_decimal:"); + asm("move.w %0, %%ccr\n\tsbcd %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : "=m" (Status) + : "d" (_A), "d" (MemValue), "m" (_A) + ); + asm(".sbc_f5_finish:"); + if (Status & 0x01) Status &= 0xFFEE; else Status |= 0x0011; + AppleClock+=4; + break; + case 0xFD: /* SBC abs, X */ + mr_eaabsx(MemValue); + if (Status & 0x01) Status &= 0xFFEE; else Status |= 0x0011; + Status |= 0x04; + asm("move.b %0, %1\n\tbne .sbc_fd_decimal" : : "m" (Decimal), "d" (Decimal)); + asm("move.w %0, %%ccr\n\tsubx.b %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : "=m" (Status) + : "d" (_A), "d" (MemValue), "m" (_A) + ); + asm("bra .sbc_fd_finish"); + asm(".sbc_fd_decimal:"); + asm("move.w %0, %%ccr\n\tsbcd %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : "=m" (Status) + : "d" (_A), "d" (MemValue), "m" (_A) + ); + asm(".sbc_fd_finish:"); + if (Status & 0x01) Status &= 0xFFEE; else Status |= 0x0011; + AppleClock+=4; + break; + case 0xF9: /* SBC abs, Y */ + mr_eaabsy(MemValue); + if (Status & 0x01) Status &= 0xFFEE; else Status |= 0x0011; + Status |= 0x04; + asm("move.b %0, %1\n\tbne .sbc_f9_decimal" : : "m" (Decimal), "d" (Decimal)); + asm("move.w %0, %%ccr\n\tsubx.b %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : "=m" (Status) + : "d" (_A), "d" (MemValue), "m" (_A) + ); + asm("bra .sbc_f9_finish"); + asm(".sbc_f9_decimal:"); + asm("move.w %0, %%ccr\n\tsbcd %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : "=m" (Status) + : "d" (_A), "d" (MemValue), "m" (_A) + ); + asm(".sbc_f9_finish:"); + if (Status & 0x01) Status &= 0xFFEE; else Status |= 0x0011; + AppleClock+=4; + break; + + case 0x38: /* SEC */ + asm("ori.w #0x11, %0" : "=m" (Status)); + AppleClock+=2; + break; + case 0xF8: /* SED */ + asm("move.b #0x08, %0" : : "m" (Decimal)); + AppleClock+=2; + break; + case 0x78: /* SEI */ + AppleClock+=2; + break; + + case 0x8D: /* STA abs */ + mw_eaabs(_A); +/* if (!LOOP) HostTraceOutputT(sysErrorClass, "STA abs : %X %X %X\n", */ +/* TempWord.PC, _A, _AppleMemory[TempWord.PC]); */ + AppleClock+=4; + break; + case 0x85: /* STA zp */ + mw_eazp(_A); + AppleClock+=3; + break; + case 0x81: /* STA (zp, X) */ + mw_eazpxind(_A); + AppleClock+=6; + break; + case 0x91: /* STA (zp), Y */ + mw_eazpindy(_A); + AppleClock+=6; + break; + case 0x95: /* STA zp, X */ + mw_eazpx(_A); + AppleClock+=4; + break; + case 0x9D: /* STA abs, X */ + mw_eaabsx(_A); + AppleClock+=5; + break; + case 0x99: /* STA abs, Y */ + mw_eaabsy(_A); +/* if (!LOOP) HostTraceOutputT(sysErrorClass, "STA abs, Y : %X %X %X %X\n", TempWord.PC, Y, _A, PreFetch); */ + AppleClock+=5; + break; + + case 0x8E: /* STX abs */ + mw_eaabs(X); + AppleClock+=4; + break; + case 0x86: /* STX zp */ + mw_eazp(X); + AppleClock+=3; + break; + case 0x96: /* STX zp, Y */ + mw_eazpy(X); + AppleClock+=4; + break; + + case 0x8C: /* STY abs */ + mw_eaabs(Y); + AppleClock+=4; + break; + case 0x84: /* STY zp */ + mw_eazp(Y); + AppleClock+=3; + break; + case 0x94: /* STY zp, X */ + mw_eazpx(Y); + AppleClock+=4; + break; + + case 0xAA: /* TAX */ + asm("move.b %0, %1\n\tmove.w %%sr, %3\n\tmove %2, %4\n\tandi.w #0x000C, %3\n\tandi.w #0xFFF3, %4\n\tor.b %3, %4\n\tmove.w %4, %2" + : + : "m" (_A), "m" (X), "m" (Status), "d" (MemValue), "d" (Status) + ); + AppleClock+=2; + break; + case 0xA8: /* TAY */ + asm("move.b %0, %1\n\tmove.w %%sr, %3\n\tmove %2, %4\n\tandi.w #0x000C, %3\n\tandi.w #0xFFF3, %4\n\tor.b %3, %4\n\tmove.w %4, %2" + : + : "m" (_A), "m" (Y), "m" (Status), "d" (MemValue), "d" (Status) + ); + AppleClock+=2; + break; + + case 0xBA: /* TSX */ + asm("move.b %0, %1\n\tmove.w %%sr, %3\n\tmove %2, %4\n\tandi.w #0x000C, %3\n\tandi.w #0xFFF3, %4\n\tor.b %3, %4\n\tmove.w %4, %2" + : + : "m" (Stack.Byte[LOW_BYTE]), "m" (X), "m" (Status), "d" (MemValue), "d" (Status) + ); + AppleClock+=2; + break; + case 0x8A: /* TXA */ + asm("move.b %0, %1\n\tmove.w %%sr, %3\n\tmove %2, %4\n\tandi.w #0x000C, %3\n\tandi.w #0xFFF3, %4\n\tor.b %3, %4\n\tmove.w %4, %2" + : + : "m" (X), "m" (_A), "m" (Status), "d" (MemValue), "d" (Status) + ); + AppleClock+=2; + break; + case 0x9A: /* TXS */ + asm("move.b %0, %1" + : + : "m" (X), "m" (Stack.Byte[LOW_BYTE]) + ); + AppleClock+=2; + break; + case 0x98: /* TYA */ + asm("move.b %0, %1\n\tmove.w %%sr, %3\n\tmove %2, %4\n\tandi.w #0x000C, %3\n\tandi.w #0xFFF3, %4\n\tor.b %3, %4\n\tmove.w %4, %2" + : + : "m" (Y), "m" (_A), "m" (Status), "d" (MemValue), "d" (Status) + ); + AppleClock+=2; + break; +/* MC6502 Instruction Set */ + case 0x72: /* ADC (zp) */ + Status &= 0xFFEF; if (Status & 0x01) Status |= 0x10; + Status |= 0x04; + mr_eazpind(MemValue); + asm("move.b %0, %1\n\tbne .adc_72_decimal" : : "m" (Decimal), "d" (Decimal)); + asm("move.w %0, %%ccr\n\taddx.b %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : + : "m" (Status), "d" (_A), "d" (MemValue), "m" (_A) + ); + asm("bra .adc_72_finish"); + asm(".adc_72_decimal:"); + asm("move.w %0, %%ccr\n\tabcd %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : + : "m" (Status), "d" (_A), "d" (MemValue), "m" (_A) + ); + asm(".adc_72_finish:"); + AppleClock+=5; + break; + case 0x32: /* AND (zp) */ + mr_eazpind(MemValue); + asm("and.b %2, %1\n\tmove.w %%sr, %3\n\tmove %0, %4\n\tandi.w #0x000C, %3\n\tandi.w #0xFFF3, %4\n\tor.b %3, %4\n\tmove.w %4, %0" + : "=m" (Status) + : "m" (_A), "d" (MemValue), "d" (Status), "d" (MemValue) + ); + AppleClock+=5; + break; + case 0x34: /* BIT zp, X */ + mr_eazpx(MemValue); + asm("andi.w #0xFFF1, %0\n\tand.b %2, %1\n\tmove.w %%sr, %3\n\tandi.w #0x04, %3\n\tor.w %3, %0\n\tclr.w %3\n\tmove.b %2, %3\n\tandi.w #0x0080, %3\n\tlsr.w #4, %3\n\tor.w %3, %0\n\tclr.w %3\n\tmove.b %2, %3\n\tandi.w #0x0040, %3\n\tlsr.w #5, %3\n\tor.w %3, %0" + : + : "m" (Status), "d" (_A), "d" (MemValue), "d" (Status) + ); + AppleClock+=3; + break; + case 0x89: /* BIT #imm */ + PC.PC++; + MemValue = PreFetch & 0xFF; + asm("andi.w #0xFFF1, %0\n\tand.b %2, %1\n\tmove.w %%sr, %3\n\tandi.w #0x04, %3\n\tor.w %3, %0\n\tclr.w %3\n\tmove.b %2, %3\n\tandi.w #0x0080, %3\n\tlsr.w #4, %3\n\tor.w %3, %0\n\tclr.w %3\n\tmove.b %2, %3\n\tandi.w #0x0040, %3\n\tlsr.w #5, %3\n\tor.w %3, %0" + : + : "m" (Status), "d" (_A), "d" (MemValue), "d" (Status) + ); + AppleClock+=2; + break; + case 0x3C: /* BIT abs, X */ + mr_eaabsx(MemValue); + asm("andi.w #0xFFF1, %0\n\tand.b %2, %1\n\tmove.w %%sr, %3\n\tandi.w #0x04, %3\n\tor.w %3, %0\n\tclr.w %3\n\tmove.b %2, %3\n\tandi.w #0x0080, %3\n\tlsr.w #4, %3\n\tor.w %3, %0\n\tclr.w %3\n\tmove.b %2, %3\n\tandi.w #0x0040, %3\n\tlsr.w #5, %3\n\tor.w %3, %0" + : + : "m" (Status), "d" (_A), "d" (MemValue), "d" (Status) + ); + AppleClock+=4; + break; + case 0x80: /* BRA rr */ + PC.PC++; + AppleClock+=3; + asm("ext.w %0" : : "d" (PreFetch)); + PC.PC += PreFetch; + break; + case 0xD2: /* CMP (zp) */ + mr_eazpind(MemValue); + asm("neg.b %1\n\tadd.b %1, %0\n\tmove %%sr, %2\n\tandi.w #0xFFF2, %3\n\tandi.w #0x000D, %2\n\tor.w %2, %3\n\tneg.b %1" + : + : "d" (_A), "d" (MemValue), "d" (Status), "m" (Status) + ); + if (_A >= MemValue) Status |= 0x01; else Status &= 0xFFFE; + AppleClock+=5; + break; + case 0x3A: /* DEA acc */ + asm("addi.b #0xFF, %0\n\tmove %%sr, %1\n\tandi.w #0x000C, %1\n\tandi.w #0xFFF3, %2\n\tor.w %1, %2" + : + : "m" (_A), "d" (Status), "m" (Status) + ); + AppleClock+=2; + break; + case 0x52: /* EOR (zp) */ + mr_eazpind(MemValue); + asm("eor.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "d" (MemValue), "m" (_A), "d" (Status), "m" (Status) + ); + AppleClock+=5; + break; + case 0x1A: /* INA acc */ + asm("addi.b #0x01, %0\n\tmove %%sr, %1\n\tandi.w #0x000C, %1\n\tandi.w #0xFFF3, %2\n\tor.w %1, %2" + : + : "m" (_A), "d" (Status), "m" (Status) + ); + AppleClock+=2; + break; + case 0x7C: /* JMP (abs, X) */ + eaabsxind(); + AppleClock+=6; + break; + case 0xB2: /* LDA (zp) */ + mr_eazpind(MemValue); + asm("move.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "d" (MemValue), "m" (_A), "d" (Status), "m" (Status) + ); + // if (!LOOP) HostTraceOutputT(sysErrorClass, "LDA (zp) : %X %X %X\n", TempWord.PC, TempByte, MemValue); + AppleClock+=5; + break; + case 0x12: /* ORA (zp) */ + mr_eazpind(MemValue); + asm("or.b %2, %1\n\tmove.w %%sr, %3\n\tmove %0, %4\n\tandi.w #0x000C, %3\n\tandi.w #0xFFF3, %4\n\tor.b %3, %4\n\tmove.w %4, %0" + : "=m" (Status) + : "m" (_A), "d" (MemValue), "d" (Status), "d" (MemValue) + ); + AppleClock+=5; + break; + case 0xDA: /* PHX */ + PUSH(X); + AppleClock+=3; + break; + case 0xFA: /* PLX */ + POP(X); + asm("move.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "m" (X), "d" (X), "d" (Status), "m" (Status) + ); + AppleClock+=4; + break; + case 0x5A: /* PHY */ + PUSH(Y); + AppleClock+=3; + break; + case 0x7A: /* PLY */ + POP(Y); + asm("move.b %0, %1\n\tmove %%sr, %2\n\tandi.w #0x000C, %2\n\tandi.w #0xFFF3, %3\n\tor.w %2, %3" + : + : "m" (Y), "d" (Y), "d" (Status), "m" (Status) + ); + AppleClock+=4; + break; + case 0xF2: /* SBC (zp) */ + mr_eazpind(MemValue); + if (Status & 0x01) Status &= 0xFFEE; else Status |= 0x0011; + Status |= 0x04; + asm("move.b %0, %1\n\tbne .sbc_f2_decimal" : : "m" (Decimal), "d" (Decimal)); + asm("move.w %0, %%ccr\n\tsubx.b %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : "=m" (Status) + : "d" (_A), "d" (MemValue), "m" (_A) + ); + asm("bra .sbc_f2_finish"); + asm(".sbc_f2_decimal:"); + asm("move.w %0, %%ccr\n\tsbcd %2, %1\n\tmove.w %%sr, %0\n\tmove.b %1, %3" + : "=m" (Status) + : "d" (_A), "d" (MemValue), "m" (_A) + ); + asm(".sbc_f2_finish:"); + if (Status & 0x01) Status &= 0xFFEE; else Status |= 0x0011; + AppleClock+=4; + break; + case 0x92: /* STA (zp) */ + mw_eazpind(_A); + AppleClock+=6; + break; + case 0x9C: /* STZ abs */ + mw_eaabs(0); + AppleClock+=3; + break; + case 0x64: /* STZ zp */ + mw_eazp(0); + AppleClock+=3; + break; + case 0x74: /* STZ zp, X */ + mw_eazpx(0); + AppleClock+=3; + break; + case 0x9E: /* STZ abs, X */ + mw_eaabsx(0); + AppleClock+=3; + break; + case 0x1C: /* TRB abs */ + mr_eaabs(MemValue); + asm("andi.w #0xFFF1, %3\n\tmove.b %0, %1\n\tandi.b #0x80, %1\n\tlsr.b #0x04, %1\n\tor.w %1, %3\n\tmove.b %0, %1\n\tand.b %4, %1\n\tmove.w %%sr, %1\n\tandi.w #0x04, %1\n\tor.w %1, %3\n\tmove.b %0, %1\n\tandi.b #0x40, %1\n\tlsr.b #0x05, %1\n\tor.w %1, %3" + : + : "d" (MemValue), "d" (_A), "m" (Status), "d" (Status), "m" (_A) + ); + MEMORY_WRITE(MemValue & ~_A, TempWord); + break; + case 0x14: /* TRB zp */ + eazp(MemValue); + asm("andi.w #0xFFF1, %3\n\tmove.b %0, %1\n\tandi.b #0x80, %1\n\tlsr.b #0x04, %1\n\tor.w %1, %3\n\tmove.b %0, %1\n\tand.b %4, %1\n\tmove.w %%sr, %1\n\tandi.w #0x04, %1\n\tor.w %1, %3\n\tmove.b %0, %1\n\tandi.b #0x40, %1\n\tlsr.b #0x05, %1\n\tor.w %1, %3" + : + : "d" (MemValue), "d" (_A), "m" (Status), "d" (Status), "m" (_A) + ); + _AppleMemory[TempByte] = MemValue; + break; + case 0x0C: /* TSB abs */ + mr_eaabs(MemValue); + asm("andi.w #0xFFF1, %3\n\tmove.b %0, %1\n\tandi.b #0x80, %1\n\tlsr.b #0x04, %1\n\tor.w %1, %3\n\tmove.b %0, %1\n\tand.b %4, %1\n\tmove.w %%sr, %1\n\tandi.w #0x04, %1\n\tor.w %1, %3\n\tmove.b %0, %1\n\tandi.b #0x40, %1\n\tlsr.b #0x05, %1\n\tor.w %1, %3" + : + : "d" (MemValue), "d" (_A), "m" (Status), "d" (Status), "m" (_A) + ); + MEMORY_WRITE(MemValue | _A, TempWord); + break; + case 0x04: /* TSB zp */ + eazp(MemValue); + asm("andi.w #0xFFF1, %3\n\tmove.b %0, %1\n\tandi.b #0x80, %1\n\tlsr.b #0x04, %1\n\tor.w %1, %3\n\tmove.b %0, %1\n\tand.b %4, %1\n\tmove.w %%sr, %1\n\tandi.w #0x04, %1\n\tor.w %1, %3\n\tmove.b %0, %1\n\tandi.b #0x40, %1\n\tlsr.b #0x05, %1\n\tor.w %1, %3" + : + : "d" (MemValue), "d" (_A), "m" (Status), "d" (Status), "m" (_A) + ); + _AppleMemory[TempByte] = MemValue | _A; + break; + default: + StrPrintF(buf, "Unknown Opcode %X", Opcode); + WinDrawChars(buf, StrLen(buf), 60, 0); + break; + } + + asm(".screen1:"); + + if (IOUSoftSwitch[0] & SS_HIRES) + *(--_pointer) = ~_AppleMemory[scanaddr--]; + else + *(--_pointer) = AppleFont[_AppleMemory[scanaddr--] * 8 + chary]; + + vert--; + + asm(".screen2:"); + + if (vert < 0) { +#ifdef SONY + vert = 39; hori--; chary--; chary &= 0x07; + if (IOUSoftSwitch[0] & SS_HIRES) + scanaddr = ScanlineAddressTableH[hori] + 39; + else + scanaddr = ScanlineAddressTable[hori] + 39; +#else + vert = 19; hori--; chary--; chary &= 0x07; + if (IOUSoftSwitch[0] & SS_HIRES) + scanaddr = ScanlineAddressTableH[hori] + 19; + else + scanaddr = ScanlineAddressTable[hori] + 19; +#endif + } + + asm(".screen3:"); + + if (hori < 0) { +#ifdef SONY + _pointer += 40 * 192; chary = 7; + vert = 39; hori = 191; fps++; + if (IOUSoftSwitch[0] & SS_HIRES) + scanaddr = ScanlineAddressTableH[hori] + 39; + else + if (IOUSoftSwitch[0] & SS_TEXT) + scanaddr = ScanlineAddressTable[hori] + 39; +#else + _pointer += 20 * 120; chary = 7; + vert = 19; hori = 119; fps++; + if (IOUSoftSwitch[0] & SS_HIRES) + scanaddr = ScanlineAddressTableH[hori] + 19; + else + if (IOUSoftSwitch[0] & SS_TEXT) + scanaddr = ScanlineAddressTable[hori] + 19; +#endif + } + + asm(".screen4:"); + + if (QUIT) goto run_again; +} diff --git a/palmapple/6502.h b/palmapple/6502.h new file mode 100644 index 0000000..ef5a41e --- /dev/null +++ b/palmapple/6502.h @@ -0,0 +1,9 @@ +#include +#include +#include + +union PCStruct { + UInt8 Byte[2]; + UInt16 PC; +}; + diff --git a/palmapple/fonts.c b/palmapple/fonts.c new file mode 100644 index 0000000..55d4437 --- /dev/null +++ b/palmapple/fonts.c @@ -0,0 +1,137 @@ +/* + * fonts.c + */ + +/* + * apple fonts bitmap files + */ + +#include "fonts/char00.bmp" +#include "fonts/char01.bmp" +#include "fonts/char02.bmp" +#include "fonts/char03.bmp" +#include "fonts/char04.bmp" +#include "fonts/char05.bmp" +#include "fonts/char06.bmp" +#include "fonts/char07.bmp" +#include "fonts/char08.bmp" +#include "fonts/char09.bmp" +#include "fonts/char0a.bmp" +#include "fonts/char0b.bmp" +#include "fonts/char0c.bmp" +#include "fonts/char0d.bmp" +#include "fonts/char0e.bmp" +#include "fonts/char0f.bmp" +#include "fonts/char10.bmp" +#include "fonts/char11.bmp" +#include "fonts/char12.bmp" +#include "fonts/char13.bmp" +#include "fonts/char14.bmp" +#include "fonts/char15.bmp" +#include "fonts/char16.bmp" +#include "fonts/char17.bmp" +#include "fonts/char18.bmp" +#include "fonts/char19.bmp" +#include "fonts/char1a.bmp" +#include "fonts/char1b.bmp" +#include "fonts/char1c.bmp" +#include "fonts/char1d.bmp" +#include "fonts/char1e.bmp" +#include "fonts/char1f.bmp" +#include "fonts/char20.bmp" +#include "fonts/char21.bmp" +#include "fonts/char22.bmp" +#include "fonts/char23.bmp" +#include "fonts/char24.bmp" +#include "fonts/char25.bmp" +#include "fonts/char26.bmp" +#include "fonts/char27.bmp" +#include "fonts/char28.bmp" +#include "fonts/char29.bmp" +#include "fonts/char2a.bmp" +#include "fonts/char2b.bmp" +#include "fonts/char2c.bmp" +#include "fonts/char2d.bmp" +#include "fonts/char2e.bmp" +#include "fonts/char2f.bmp" +#include "fonts/char30.bmp" +#include "fonts/char31.bmp" +#include "fonts/char32.bmp" +#include "fonts/char33.bmp" +#include "fonts/char34.bmp" +#include "fonts/char35.bmp" +#include "fonts/char36.bmp" +#include "fonts/char37.bmp" +#include "fonts/char38.bmp" +#include "fonts/char39.bmp" +#include "fonts/char3a.bmp" +#include "fonts/char3b.bmp" +#include "fonts/char3c.bmp" +#include "fonts/char3d.bmp" +#include "fonts/char3e.bmp" +#include "fonts/char3f.bmp" +#include "fonts/char40.bmp" +#include "fonts/char41.bmp" +#include "fonts/char42.bmp" +#include "fonts/char43.bmp" +#include "fonts/char44.bmp" +#include "fonts/char45.bmp" +#include "fonts/char46.bmp" +#include "fonts/char47.bmp" +#include "fonts/char48.bmp" +#include "fonts/char49.bmp" +#include "fonts/char4a.bmp" +#include "fonts/char4b.bmp" +#include "fonts/char4c.bmp" +#include "fonts/char4d.bmp" +#include "fonts/char4e.bmp" +#include "fonts/char4f.bmp" +#include "fonts/char50.bmp" +#include "fonts/char51.bmp" +#include "fonts/char52.bmp" +#include "fonts/char53.bmp" +#include "fonts/char54.bmp" +#include "fonts/char55.bmp" +#include "fonts/char56.bmp" +#include "fonts/char57.bmp" +#include "fonts/char58.bmp" +#include "fonts/char59.bmp" +#include "fonts/char5a.bmp" +#include "fonts/char5b.bmp" +#include "fonts/char5c.bmp" +#include "fonts/char5d.bmp" +#include "fonts/char5e.bmp" +#include "fonts/char5f.bmp" + +/* + * bitmap index array + */ + +#define MAX_CHAR_BITMAP 0x60 + +char *AppleFontBitmap[MAX_CHAR_BITMAP] = { + char00_bits, char01_bits, char02_bits, char03_bits, + char04_bits, char05_bits, char06_bits, char07_bits, + char08_bits, char09_bits, char0a_bits, char0b_bits, + char0c_bits, char0d_bits, char0e_bits, char0f_bits, + char10_bits, char11_bits, char12_bits, char13_bits, + char14_bits, char15_bits, char16_bits, char17_bits, + char18_bits, char19_bits, char1a_bits, char1b_bits, + char1c_bits, char1d_bits, char1e_bits, char1f_bits, + char20_bits, char21_bits, char22_bits, char23_bits, + char24_bits, char25_bits, char26_bits, char27_bits, + char28_bits, char29_bits, char2a_bits, char2b_bits, + char2c_bits, char2d_bits, char2e_bits, char2f_bits, + char30_bits, char31_bits, char32_bits, char33_bits, + char34_bits, char35_bits, char36_bits, char37_bits, + char38_bits, char39_bits, char3a_bits, char3b_bits, + char3c_bits, char3d_bits, char3e_bits, char3f_bits, + char40_bits, char41_bits, char42_bits, char43_bits, + char44_bits, char45_bits, char46_bits, char47_bits, + char48_bits, char49_bits, char4a_bits, char4b_bits, + char4c_bits, char4d_bits, char4e_bits, char4f_bits, + char50_bits, char51_bits, char52_bits, char53_bits, + char54_bits, char55_bits, char56_bits, char57_bits, + char58_bits, char59_bits, char5a_bits, char5b_bits, + char5c_bits, char5d_bits, char5e_bits, char5f_bits, +}; diff --git a/palmapple/fonts/char00.bmp b/palmapple/fonts/char00.bmp new file mode 100644 index 0000000..bf67cf3 --- /dev/null +++ b/palmapple/fonts/char00.bmp @@ -0,0 +1,3 @@ +#define char00_width 7 +#define char00_height 8 +static char char00_bits[] = {0x3c, 0x44, 0x54, 0x5c, 0x58, 0x40, 0x3c, 0x0}; diff --git a/palmapple/fonts/char01.bmp b/palmapple/fonts/char01.bmp new file mode 100644 index 0000000..ef8e7cc --- /dev/null +++ b/palmapple/fonts/char01.bmp @@ -0,0 +1,3 @@ +#define char01_width 7 +#define char01_height 8 +static char char01_bits[] = {0x10, 0x28, 0x44, 0x44, 0x7c, 0x44, 0x44, 0x0}; diff --git a/palmapple/fonts/char02.bmp b/palmapple/fonts/char02.bmp new file mode 100644 index 0000000..7acd18c --- /dev/null +++ b/palmapple/fonts/char02.bmp @@ -0,0 +1,3 @@ +#define char02_width 7 +#define char02_height 8 +static char char02_bits[] = {0x78, 0x44, 0x44, 0x78, 0x44, 0x44, 0x78, 0x0}; diff --git a/palmapple/fonts/char03.bmp b/palmapple/fonts/char03.bmp new file mode 100644 index 0000000..77ca0ae --- /dev/null +++ b/palmapple/fonts/char03.bmp @@ -0,0 +1,3 @@ +#define char03_width 7 +#define char03_height 8 +static char char03_bits[] = {0x38, 0x44, 0x40, 0x40, 0x40, 0x44, 0x38, 0x0}; diff --git a/palmapple/fonts/char04.bmp b/palmapple/fonts/char04.bmp new file mode 100644 index 0000000..aab816e --- /dev/null +++ b/palmapple/fonts/char04.bmp @@ -0,0 +1,3 @@ +#define char04_width 7 +#define char04_height 8 +static char char04_bits[] = {0x78, 0x44, 0x44, 0x44, 0x44, 0x44, 0x78, 0x0}; diff --git a/palmapple/fonts/char05.bmp b/palmapple/fonts/char05.bmp new file mode 100644 index 0000000..54e57e2 --- /dev/null +++ b/palmapple/fonts/char05.bmp @@ -0,0 +1,3 @@ +#define char05_width 7 +#define char05_height 8 +static char char05_bits[] = {0x7c, 0x40, 0x40, 0x78, 0x40, 0x40, 0x7c, 0x0}; diff --git a/palmapple/fonts/char06.bmp b/palmapple/fonts/char06.bmp new file mode 100644 index 0000000..19f9314 --- /dev/null +++ b/palmapple/fonts/char06.bmp @@ -0,0 +1,3 @@ +#define char06_width 7 +#define char06_height 8 +static char char06_bits[] = {0x7c, 0x40, 0x40, 0x78, 0x40, 0x40, 0x40, 0x0}; diff --git a/palmapple/fonts/char07.bmp b/palmapple/fonts/char07.bmp new file mode 100644 index 0000000..3f82f91 --- /dev/null +++ b/palmapple/fonts/char07.bmp @@ -0,0 +1,3 @@ +#define char07_width 7 +#define char07_height 8 +static char char07_bits[] = {0x3c, 0x40, 0x40, 0x40, 0x4c, 0x44, 0x3c, 0x0}; diff --git a/palmapple/fonts/char08.bmp b/palmapple/fonts/char08.bmp new file mode 100644 index 0000000..88ddb3c --- /dev/null +++ b/palmapple/fonts/char08.bmp @@ -0,0 +1,3 @@ +#define char08_width 7 +#define char08_height 8 +static char char08_bits[] = {0x44, 0x44, 0x44, 0x7c, 0x44, 0x44, 0x44, 0x0}; diff --git a/palmapple/fonts/char09.bmp b/palmapple/fonts/char09.bmp new file mode 100644 index 0000000..b2fa749 --- /dev/null +++ b/palmapple/fonts/char09.bmp @@ -0,0 +1,3 @@ +#define char09_width 7 +#define char09_height 8 +static char char09_bits[] = {0x38, 0x10, 0x10, 0x10, 0x10, 0x10, 0x38, 0x0}; diff --git a/palmapple/fonts/char0a.bmp b/palmapple/fonts/char0a.bmp new file mode 100644 index 0000000..aa55bc1 --- /dev/null +++ b/palmapple/fonts/char0a.bmp @@ -0,0 +1,3 @@ +#define char0a_width 7 +#define char0a_height 8 +static char char0a_bits[] = {0x4, 0x4, 0x4, 0x4, 0x4, 0x44, 0x38, 0x0}; diff --git a/palmapple/fonts/char0b.bmp b/palmapple/fonts/char0b.bmp new file mode 100644 index 0000000..5bc5025 --- /dev/null +++ b/palmapple/fonts/char0b.bmp @@ -0,0 +1,3 @@ +#define char0b_width 7 +#define char0b_height 8 +static char char0b_bits[] = {0x44, 0x48, 0x50, 0x60, 0x50, 0x48, 0x44, 0x0}; diff --git a/palmapple/fonts/char0c.bmp b/palmapple/fonts/char0c.bmp new file mode 100644 index 0000000..96fc2ff --- /dev/null +++ b/palmapple/fonts/char0c.bmp @@ -0,0 +1,3 @@ +#define char0c_width 7 +#define char0c_height 8 +static char char0c_bits[] = {0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7c, 0x0}; diff --git a/palmapple/fonts/char0d.bmp b/palmapple/fonts/char0d.bmp new file mode 100644 index 0000000..3e1a630 --- /dev/null +++ b/palmapple/fonts/char0d.bmp @@ -0,0 +1,3 @@ +#define char0d_width 7 +#define char0d_height 8 +static char char0d_bits[] = {0x44, 0x6c, 0x54, 0x54, 0x44, 0x44, 0x44, 0x0}; diff --git a/palmapple/fonts/char0e.bmp b/palmapple/fonts/char0e.bmp new file mode 100644 index 0000000..6191c62 --- /dev/null +++ b/palmapple/fonts/char0e.bmp @@ -0,0 +1,3 @@ +#define char0e_width 7 +#define char0e_height 8 +static char char0e_bits[] = {0x44, 0x44, 0x64, 0x54, 0x4c, 0x44, 0x44, 0x0}; diff --git a/palmapple/fonts/char0f.bmp b/palmapple/fonts/char0f.bmp new file mode 100644 index 0000000..108f9e7 --- /dev/null +++ b/palmapple/fonts/char0f.bmp @@ -0,0 +1,3 @@ +#define char0f_width 7 +#define char0f_height 8 +static char char0f_bits[] = {0x38, 0x44, 0x44, 0x44, 0x44, 0x44, 0x38, 0x0}; diff --git a/palmapple/fonts/char10.bmp b/palmapple/fonts/char10.bmp new file mode 100644 index 0000000..db07369 --- /dev/null +++ b/palmapple/fonts/char10.bmp @@ -0,0 +1,3 @@ +#define char10_width 7 +#define char10_height 8 +static char char10_bits[] = {0x78, 0x44, 0x44, 0x78, 0x40, 0x40, 0x40, 0x0}; diff --git a/palmapple/fonts/char11.bmp b/palmapple/fonts/char11.bmp new file mode 100644 index 0000000..0cb95fc --- /dev/null +++ b/palmapple/fonts/char11.bmp @@ -0,0 +1,3 @@ +#define char11_width 7 +#define char11_height 8 +static char char11_bits[] = {0x38, 0x44, 0x44, 0x44, 0x54, 0x48, 0x34, 0x0}; diff --git a/palmapple/fonts/char12.bmp b/palmapple/fonts/char12.bmp new file mode 100644 index 0000000..ed50cd8 --- /dev/null +++ b/palmapple/fonts/char12.bmp @@ -0,0 +1,3 @@ +#define char12_width 7 +#define char12_height 8 +static char char12_bits[] = {0x78, 0x44, 0x44, 0x78, 0x50, 0x48, 0x44, 0x0}; diff --git a/palmapple/fonts/char13.bmp b/palmapple/fonts/char13.bmp new file mode 100644 index 0000000..8d35d0a --- /dev/null +++ b/palmapple/fonts/char13.bmp @@ -0,0 +1,3 @@ +#define char13_width 7 +#define char13_height 8 +static char char13_bits[] = {0x38, 0x44, 0x40, 0x38, 0x4, 0x44, 0x38, 0x0}; diff --git a/palmapple/fonts/char14.bmp b/palmapple/fonts/char14.bmp new file mode 100644 index 0000000..28ed855 --- /dev/null +++ b/palmapple/fonts/char14.bmp @@ -0,0 +1,3 @@ +#define char14_width 7 +#define char14_height 8 +static char char14_bits[] = {0x7c, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x0}; diff --git a/palmapple/fonts/char15.bmp b/palmapple/fonts/char15.bmp new file mode 100644 index 0000000..70e4e70 --- /dev/null +++ b/palmapple/fonts/char15.bmp @@ -0,0 +1,3 @@ +#define char15_width 7 +#define char15_height 8 +static char char15_bits[] = {0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x38, 0x0}; diff --git a/palmapple/fonts/char16.bmp b/palmapple/fonts/char16.bmp new file mode 100644 index 0000000..410dd20 --- /dev/null +++ b/palmapple/fonts/char16.bmp @@ -0,0 +1,3 @@ +#define char16_width 7 +#define char16_height 8 +static char char16_bits[] = {0x44, 0x44, 0x44, 0x44, 0x44, 0x28, 0x10, 0x0}; diff --git a/palmapple/fonts/char17.bmp b/palmapple/fonts/char17.bmp new file mode 100644 index 0000000..d1b893f --- /dev/null +++ b/palmapple/fonts/char17.bmp @@ -0,0 +1,3 @@ +#define char17_width 7 +#define char17_height 8 +static char char17_bits[] = {0x44, 0x44, 0x44, 0x54, 0x54, 0x6c, 0x44, 0x0}; diff --git a/palmapple/fonts/char18.bmp b/palmapple/fonts/char18.bmp new file mode 100644 index 0000000..befbc75 --- /dev/null +++ b/palmapple/fonts/char18.bmp @@ -0,0 +1,3 @@ +#define char18_width 7 +#define char18_height 8 +static char char18_bits[] = {0x44, 0x44, 0x28, 0x10, 0x28, 0x44, 0x44, 0x0}; diff --git a/palmapple/fonts/char19.bmp b/palmapple/fonts/char19.bmp new file mode 100644 index 0000000..d993a17 --- /dev/null +++ b/palmapple/fonts/char19.bmp @@ -0,0 +1,3 @@ +#define char19_width 7 +#define char19_height 8 +static char char19_bits[] = {0x44, 0x44, 0x28, 0x10, 0x10, 0x10, 0x10, 0x0}; diff --git a/palmapple/fonts/char1a.bmp b/palmapple/fonts/char1a.bmp new file mode 100644 index 0000000..9904bfb --- /dev/null +++ b/palmapple/fonts/char1a.bmp @@ -0,0 +1,3 @@ +#define char1a_width 7 +#define char1a_height 8 +static char char1a_bits[] = {0x7c, 0x4, 0x8, 0x10, 0x20, 0x40, 0x7c, 0x0}; diff --git a/palmapple/fonts/char1b.bmp b/palmapple/fonts/char1b.bmp new file mode 100644 index 0000000..28863dc --- /dev/null +++ b/palmapple/fonts/char1b.bmp @@ -0,0 +1,3 @@ +#define char1b_width 7 +#define char1b_height 8 +static char char1b_bits[] = {0x7c, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7c, 0x0}; diff --git a/palmapple/fonts/char1c.bmp b/palmapple/fonts/char1c.bmp new file mode 100644 index 0000000..12134f6 --- /dev/null +++ b/palmapple/fonts/char1c.bmp @@ -0,0 +1,3 @@ +#define char1c_width 7 +#define char1c_height 8 +static char char1c_bits[] = {0x0, 0x40, 0x20, 0x10, 0x8, 0x4, 0x0, 0x0}; diff --git a/palmapple/fonts/char1d.bmp b/palmapple/fonts/char1d.bmp new file mode 100644 index 0000000..76ae7fd --- /dev/null +++ b/palmapple/fonts/char1d.bmp @@ -0,0 +1,3 @@ +#define char1d_width 7 +#define char1d_height 8 +static char char1d_bits[] = {0x7c, 0xc, 0xc, 0xc, 0xc, 0xc, 0x7c, 0x0}; diff --git a/palmapple/fonts/char1e.bmp b/palmapple/fonts/char1e.bmp new file mode 100644 index 0000000..de0dbba --- /dev/null +++ b/palmapple/fonts/char1e.bmp @@ -0,0 +1,3 @@ +#define char1e_width 7 +#define char1e_height 8 +static char char1e_bits[] = {0x0, 0x0, 0x10, 0x28, 0x44, 0x0, 0x0, 0x0}; diff --git a/palmapple/fonts/char1f.bmp b/palmapple/fonts/char1f.bmp new file mode 100644 index 0000000..a8a4bcf --- /dev/null +++ b/palmapple/fonts/char1f.bmp @@ -0,0 +1,3 @@ +#define char1f_width 7 +#define char1f_height 8 +static char char1f_bits[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe}; diff --git a/palmapple/fonts/char20.bmp b/palmapple/fonts/char20.bmp new file mode 100644 index 0000000..8f6e25a --- /dev/null +++ b/palmapple/fonts/char20.bmp @@ -0,0 +1,3 @@ +#define char20_width 7 +#define char20_height 8 +static char char20_bits[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; diff --git a/palmapple/fonts/char21.bmp b/palmapple/fonts/char21.bmp new file mode 100644 index 0000000..537b571 --- /dev/null +++ b/palmapple/fonts/char21.bmp @@ -0,0 +1,3 @@ +#define char21_width 7 +#define char21_height 8 +static char char21_bits[] = {0x10, 0x10, 0x10, 0x10, 0x10, 0x0, 0x10, 0x0}; diff --git a/palmapple/fonts/char22.bmp b/palmapple/fonts/char22.bmp new file mode 100644 index 0000000..f4fceb4 --- /dev/null +++ b/palmapple/fonts/char22.bmp @@ -0,0 +1,3 @@ +#define char22_width 7 +#define char22_height 8 +static char char22_bits[] = {0x28, 0x28, 0x28, 0x0, 0x0, 0x0, 0x0, 0x0}; diff --git a/palmapple/fonts/char23.bmp b/palmapple/fonts/char23.bmp new file mode 100644 index 0000000..a851d21 --- /dev/null +++ b/palmapple/fonts/char23.bmp @@ -0,0 +1,3 @@ +#define char23_width 7 +#define char23_height 8 +static char char23_bits[] = {0x28, 0x28, 0xfe, 0x28, 0xfe, 0x28, 0x28, 0x0}; diff --git a/palmapple/fonts/char24.bmp b/palmapple/fonts/char24.bmp new file mode 100644 index 0000000..7c8d8f7 --- /dev/null +++ b/palmapple/fonts/char24.bmp @@ -0,0 +1,3 @@ +#define char24_width 7 +#define char24_height 8 +static char char24_bits[] = {0x10, 0x3c, 0x50, 0x38, 0x14, 0x78, 0x10, 0x0}; diff --git a/palmapple/fonts/char25.bmp b/palmapple/fonts/char25.bmp new file mode 100644 index 0000000..5687728 --- /dev/null +++ b/palmapple/fonts/char25.bmp @@ -0,0 +1,3 @@ +#define char25_width 7 +#define char25_height 8 +static char char25_bits[] = {0x60, 0x64, 0x8, 0x10, 0x20, 0x4c, 0xc, 0x0}; diff --git a/palmapple/fonts/char26.bmp b/palmapple/fonts/char26.bmp new file mode 100644 index 0000000..0f9387b --- /dev/null +++ b/palmapple/fonts/char26.bmp @@ -0,0 +1,3 @@ +#define char26_width 7 +#define char26_height 8 +static char char26_bits[] = {0x20, 0x50, 0x50, 0x20, 0x54, 0x48, 0x34, 0x0}; diff --git a/palmapple/fonts/char27.bmp b/palmapple/fonts/char27.bmp new file mode 100644 index 0000000..4b618ee --- /dev/null +++ b/palmapple/fonts/char27.bmp @@ -0,0 +1,3 @@ +#define char27_width 7 +#define char27_height 8 +static char char27_bits[] = {0x10, 0x10, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0}; diff --git a/palmapple/fonts/char28.bmp b/palmapple/fonts/char28.bmp new file mode 100644 index 0000000..aedef66 --- /dev/null +++ b/palmapple/fonts/char28.bmp @@ -0,0 +1,3 @@ +#define char28_width 7 +#define char28_height 8 +static char char28_bits[] = {0x10, 0x20, 0x40, 0x40, 0x40, 0x20, 0x10, 0x0}; diff --git a/palmapple/fonts/char29.bmp b/palmapple/fonts/char29.bmp new file mode 100644 index 0000000..4394755 --- /dev/null +++ b/palmapple/fonts/char29.bmp @@ -0,0 +1,3 @@ +#define char29_width 7 +#define char29_height 8 +static char char29_bits[] = {0x10, 0x8, 0x4, 0x4, 0x4, 0x8, 0x10, 0x0}; diff --git a/palmapple/fonts/char2a.bmp b/palmapple/fonts/char2a.bmp new file mode 100644 index 0000000..75310b1 --- /dev/null +++ b/palmapple/fonts/char2a.bmp @@ -0,0 +1,3 @@ +#define char2a_width 7 +#define char2a_height 8 +static char char2a_bits[] = {0x10, 0x54, 0x38, 0x10, 0x38, 0x54, 0x10, 0x0}; diff --git a/palmapple/fonts/char2b.bmp b/palmapple/fonts/char2b.bmp new file mode 100644 index 0000000..fc5bfb6 --- /dev/null +++ b/palmapple/fonts/char2b.bmp @@ -0,0 +1,3 @@ +#define char2b_width 7 +#define char2b_height 8 +static char char2b_bits[] = {0x0, 0x10, 0x10, 0x7c, 0x10, 0x10, 0x0, 0x0}; diff --git a/palmapple/fonts/char2c.bmp b/palmapple/fonts/char2c.bmp new file mode 100644 index 0000000..f901639 --- /dev/null +++ b/palmapple/fonts/char2c.bmp @@ -0,0 +1,3 @@ +#define char2c_width 7 +#define char2c_height 8 +static char char2c_bits[] = {0x0, 0x0, 0x0, 0x0, 0x10, 0x10, 0x20, 0x0}; diff --git a/palmapple/fonts/char2d.bmp b/palmapple/fonts/char2d.bmp new file mode 100644 index 0000000..fede6fc --- /dev/null +++ b/palmapple/fonts/char2d.bmp @@ -0,0 +1,3 @@ +#define char2d_width 7 +#define char2d_height 8 +static char char2d_bits[] = {0x0, 0x0, 0x0, 0x7c, 0x0, 0x0, 0x0, 0x0}; diff --git a/palmapple/fonts/char2e.bmp b/palmapple/fonts/char2e.bmp new file mode 100644 index 0000000..65fe23c --- /dev/null +++ b/palmapple/fonts/char2e.bmp @@ -0,0 +1,3 @@ +#define char2e_width 7 +#define char2e_height 8 +static char char2e_bits[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0}; diff --git a/palmapple/fonts/char2f.bmp b/palmapple/fonts/char2f.bmp new file mode 100644 index 0000000..f0eb75c --- /dev/null +++ b/palmapple/fonts/char2f.bmp @@ -0,0 +1,3 @@ +#define char2f_width 7 +#define char2f_height 8 +static char char2f_bits[] = {0x0, 0x4, 0x8, 0x10, 0x20, 0x40, 0x0, 0x0}; diff --git a/palmapple/fonts/char30.bmp b/palmapple/fonts/char30.bmp new file mode 100644 index 0000000..0e312f9 --- /dev/null +++ b/palmapple/fonts/char30.bmp @@ -0,0 +1,3 @@ +#define char30_width 7 +#define char30_height 8 +static char char30_bits[] = {0x38, 0x44, 0x4c, 0x54, 0x64, 0x44, 0x38, 0x0}; diff --git a/palmapple/fonts/char31.bmp b/palmapple/fonts/char31.bmp new file mode 100644 index 0000000..588ecb6 --- /dev/null +++ b/palmapple/fonts/char31.bmp @@ -0,0 +1,3 @@ +#define char31_width 7 +#define char31_height 8 +static char char31_bits[] = {0x10, 0x30, 0x10, 0x10, 0x10, 0x10, 0x38, 0x0}; diff --git a/palmapple/fonts/char32.bmp b/palmapple/fonts/char32.bmp new file mode 100644 index 0000000..0327870 --- /dev/null +++ b/palmapple/fonts/char32.bmp @@ -0,0 +1,3 @@ +#define char32_width 7 +#define char32_height 8 +static char char32_bits[] = {0x38, 0x44, 0x4, 0x18, 0x20, 0x40, 0x7c, 0x0}; diff --git a/palmapple/fonts/char33.bmp b/palmapple/fonts/char33.bmp new file mode 100644 index 0000000..1782692 --- /dev/null +++ b/palmapple/fonts/char33.bmp @@ -0,0 +1,3 @@ +#define char33_width 7 +#define char33_height 8 +static char char33_bits[] = {0x7c, 0x4, 0x8, 0x18, 0x4, 0x44, 0x38, 0x0}; diff --git a/palmapple/fonts/char34.bmp b/palmapple/fonts/char34.bmp new file mode 100644 index 0000000..cd3fcc7 --- /dev/null +++ b/palmapple/fonts/char34.bmp @@ -0,0 +1,3 @@ +#define char34_width 7 +#define char34_height 8 +static char char34_bits[] = {0x8, 0x18, 0x28, 0x48, 0x7c, 0x8, 0x8, 0x0}; diff --git a/palmapple/fonts/char35.bmp b/palmapple/fonts/char35.bmp new file mode 100644 index 0000000..03f68f9 --- /dev/null +++ b/palmapple/fonts/char35.bmp @@ -0,0 +1,3 @@ +#define char35_width 7 +#define char35_height 8 +static char char35_bits[] = {0x7c, 0x40, 0x78, 0x4, 0x4, 0x44, 0x38, 0x0}; diff --git a/palmapple/fonts/char36.bmp b/palmapple/fonts/char36.bmp new file mode 100644 index 0000000..5d21495 --- /dev/null +++ b/palmapple/fonts/char36.bmp @@ -0,0 +1,3 @@ +#define char36_width 7 +#define char36_height 8 +static char char36_bits[] = {0x1c, 0x20, 0x40, 0x78, 0x44, 0x44, 0x38, 0x0}; diff --git a/palmapple/fonts/char37.bmp b/palmapple/fonts/char37.bmp new file mode 100644 index 0000000..21b3d47 --- /dev/null +++ b/palmapple/fonts/char37.bmp @@ -0,0 +1,3 @@ +#define char37_width 7 +#define char37_height 8 +static char char37_bits[] = {0x7c, 0x4, 0x8, 0x10, 0x20, 0x20, 0x20, 0x0}; diff --git a/palmapple/fonts/char38.bmp b/palmapple/fonts/char38.bmp new file mode 100644 index 0000000..dd73095 --- /dev/null +++ b/palmapple/fonts/char38.bmp @@ -0,0 +1,3 @@ +#define char38_width 7 +#define char38_height 8 +static char char38_bits[] = {0x38, 0x44, 0x44, 0x38, 0x44, 0x44, 0x38, 0x0}; diff --git a/palmapple/fonts/char39.bmp b/palmapple/fonts/char39.bmp new file mode 100644 index 0000000..bccb8fc --- /dev/null +++ b/palmapple/fonts/char39.bmp @@ -0,0 +1,3 @@ +#define char39_width 7 +#define char39_height 8 +static char char39_bits[] = {0x38, 0x44, 0x44, 0x3c, 0x4, 0x8, 0x70, 0x0}; diff --git a/palmapple/fonts/char3a.bmp b/palmapple/fonts/char3a.bmp new file mode 100644 index 0000000..005a6f3 --- /dev/null +++ b/palmapple/fonts/char3a.bmp @@ -0,0 +1,3 @@ +#define char3a_width 7 +#define char3a_height 8 +static char char3a_bits[] = {0x0, 0x0, 0x10, 0x0, 0x10, 0x0, 0x0, 0x0}; diff --git a/palmapple/fonts/char3b.bmp b/palmapple/fonts/char3b.bmp new file mode 100644 index 0000000..cbd198c --- /dev/null +++ b/palmapple/fonts/char3b.bmp @@ -0,0 +1,3 @@ +#define char3b_width 7 +#define char3b_height 8 +static char char3b_bits[] = {0x0, 0x0, 0x10, 0x0, 0x10, 0x10, 0x20, 0x0}; diff --git a/palmapple/fonts/char3c.bmp b/palmapple/fonts/char3c.bmp new file mode 100644 index 0000000..ac4b443 --- /dev/null +++ b/palmapple/fonts/char3c.bmp @@ -0,0 +1,3 @@ +#define char3c_width 7 +#define char3c_height 8 +static char char3c_bits[] = {0x8, 0x10, 0x20, 0x40, 0x20, 0x10, 0x8, 0x0}; diff --git a/palmapple/fonts/char3d.bmp b/palmapple/fonts/char3d.bmp new file mode 100644 index 0000000..0883bce --- /dev/null +++ b/palmapple/fonts/char3d.bmp @@ -0,0 +1,3 @@ +#define char3d_width 7 +#define char3d_height 8 +static char char3d_bits[] = {0x0, 0x0, 0x7c, 0x0, 0x7c, 0x0, 0x0, 0x0}; diff --git a/palmapple/fonts/char3e.bmp b/palmapple/fonts/char3e.bmp new file mode 100644 index 0000000..c938bbf --- /dev/null +++ b/palmapple/fonts/char3e.bmp @@ -0,0 +1,3 @@ +#define char3e_width 7 +#define char3e_height 8 +static char char3e_bits[] = {0x20, 0x10, 0x8, 0x4, 0x8, 0x10, 0x20, 0x0}; diff --git a/palmapple/fonts/char3f.bmp b/palmapple/fonts/char3f.bmp new file mode 100644 index 0000000..214704c --- /dev/null +++ b/palmapple/fonts/char3f.bmp @@ -0,0 +1,3 @@ +#define char3f_width 7 +#define char3f_height 8 +static char char3f_bits[] = {0x38, 0x44, 0x8, 0x10, 0x10, 0x0, 0x10, 0x0}; diff --git a/palmapple/fonts/char40.bmp b/palmapple/fonts/char40.bmp new file mode 100644 index 0000000..d473a5c --- /dev/null +++ b/palmapple/fonts/char40.bmp @@ -0,0 +1,3 @@ +#define char40_width 7 +#define char40_height 8 +static char char40_bits[] = {0x20, 0x10, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0}; diff --git a/palmapple/fonts/char41.bmp b/palmapple/fonts/char41.bmp new file mode 100644 index 0000000..cc9d36e --- /dev/null +++ b/palmapple/fonts/char41.bmp @@ -0,0 +1,3 @@ +#define char41_width 7 +#define char41_height 8 +static char char41_bits[] = {0x0, 0x0, 0x38, 0x4, 0x3c, 0x44, 0x3c, 0x0}; diff --git a/palmapple/fonts/char42.bmp b/palmapple/fonts/char42.bmp new file mode 100644 index 0000000..6dab8b4 --- /dev/null +++ b/palmapple/fonts/char42.bmp @@ -0,0 +1,3 @@ +#define char42_width 7 +#define char42_height 8 +static char char42_bits[] = {0x40, 0x40, 0x78, 0x44, 0x44, 0x44, 0x78, 0x0}; diff --git a/palmapple/fonts/char43.bmp b/palmapple/fonts/char43.bmp new file mode 100644 index 0000000..42e9d24 --- /dev/null +++ b/palmapple/fonts/char43.bmp @@ -0,0 +1,3 @@ +#define char43_width 7 +#define char43_height 8 +static char char43_bits[] = {0x0, 0x0, 0x3c, 0x40, 0x40, 0x40, 0x3c, 0x0}; diff --git a/palmapple/fonts/char44.bmp b/palmapple/fonts/char44.bmp new file mode 100644 index 0000000..47854fa --- /dev/null +++ b/palmapple/fonts/char44.bmp @@ -0,0 +1,3 @@ +#define char44_width 7 +#define char44_height 8 +static char char44_bits[] = {0x4, 0x4, 0x3c, 0x44, 0x44, 0x44, 0x3c, 0x0}; diff --git a/palmapple/fonts/char45.bmp b/palmapple/fonts/char45.bmp new file mode 100644 index 0000000..f7c51dd --- /dev/null +++ b/palmapple/fonts/char45.bmp @@ -0,0 +1,3 @@ +#define char45_width 7 +#define char45_height 8 +static char char45_bits[] = {0x0, 0x0, 0x38, 0x44, 0x7c, 0x40, 0x3c, 0x0}; diff --git a/palmapple/fonts/char46.bmp b/palmapple/fonts/char46.bmp new file mode 100644 index 0000000..2564dad --- /dev/null +++ b/palmapple/fonts/char46.bmp @@ -0,0 +1,3 @@ +#define char46_width 7 +#define char46_height 8 +static char char46_bits[] = {0x18, 0x24, 0x20, 0x78, 0x20, 0x20, 0x20, 0x0}; diff --git a/palmapple/fonts/char47.bmp b/palmapple/fonts/char47.bmp new file mode 100644 index 0000000..69bad0a --- /dev/null +++ b/palmapple/fonts/char47.bmp @@ -0,0 +1,3 @@ +#define char47_width 7 +#define char47_height 8 +static char char47_bits[] = {0x0, 0x0, 0x38, 0x44, 0x44, 0x3c, 0x4, 0x38}; diff --git a/palmapple/fonts/char48.bmp b/palmapple/fonts/char48.bmp new file mode 100644 index 0000000..9b1a485 --- /dev/null +++ b/palmapple/fonts/char48.bmp @@ -0,0 +1,3 @@ +#define char48_width 7 +#define char48_height 8 +static char char48_bits[] = {0x40, 0x40, 0x78, 0x44, 0x44, 0x44, 0x44, 0x0}; diff --git a/palmapple/fonts/char49.bmp b/palmapple/fonts/char49.bmp new file mode 100644 index 0000000..c25b402 --- /dev/null +++ b/palmapple/fonts/char49.bmp @@ -0,0 +1,3 @@ +#define char49_width 7 +#define char49_height 8 +static char char49_bits[] = {0x10, 0x0, 0x30, 0x10, 0x10, 0x10, 0x38, 0x0}; diff --git a/palmapple/fonts/char4a.bmp b/palmapple/fonts/char4a.bmp new file mode 100644 index 0000000..8068f84 --- /dev/null +++ b/palmapple/fonts/char4a.bmp @@ -0,0 +1,3 @@ +#define char4a_width 7 +#define char4a_height 8 +static char char4a_bits[] = {0x8, 0x0, 0x38, 0x8, 0x8, 0x8, 0x48, 0x30}; diff --git a/palmapple/fonts/char4b.bmp b/palmapple/fonts/char4b.bmp new file mode 100644 index 0000000..ff16264 --- /dev/null +++ b/palmapple/fonts/char4b.bmp @@ -0,0 +1,3 @@ +#define char4b_width 7 +#define char4b_height 8 +static char char4b_bits[] = {0x40, 0x40, 0x44, 0x48, 0x70, 0x48, 0x44, 0x0}; diff --git a/palmapple/fonts/char4c.bmp b/palmapple/fonts/char4c.bmp new file mode 100644 index 0000000..4e83cb0 --- /dev/null +++ b/palmapple/fonts/char4c.bmp @@ -0,0 +1,3 @@ +#define char4c_width 7 +#define char4c_height 8 +static char char4c_bits[] = {0x30, 0x10, 0x10, 0x10, 0x10, 0x10, 0x38, 0x0}; diff --git a/palmapple/fonts/char4d.bmp b/palmapple/fonts/char4d.bmp new file mode 100644 index 0000000..3cdfbc2 --- /dev/null +++ b/palmapple/fonts/char4d.bmp @@ -0,0 +1,3 @@ +#define char4d_width 7 +#define char4d_height 8 +static char char4d_bits[] = {0x0, 0x0, 0x6c, 0x54, 0x54, 0x54, 0x44, 0x0}; diff --git a/palmapple/fonts/char4e.bmp b/palmapple/fonts/char4e.bmp new file mode 100644 index 0000000..d09b91d --- /dev/null +++ b/palmapple/fonts/char4e.bmp @@ -0,0 +1,3 @@ +#define char4e_width 7 +#define char4e_height 8 +static char char4e_bits[] = {0x0, 0x0, 0x78, 0x44, 0x44, 0x44, 0x44, 0x0}; diff --git a/palmapple/fonts/char4f.bmp b/palmapple/fonts/char4f.bmp new file mode 100644 index 0000000..25bcc4b --- /dev/null +++ b/palmapple/fonts/char4f.bmp @@ -0,0 +1,3 @@ +#define char4f_width 7 +#define char4f_height 8 +static char char4f_bits[] = {0x0, 0x0, 0x38, 0x44, 0x44, 0x44, 0x38, 0x0}; diff --git a/palmapple/fonts/char50.bmp b/palmapple/fonts/char50.bmp new file mode 100644 index 0000000..cce46c7 --- /dev/null +++ b/palmapple/fonts/char50.bmp @@ -0,0 +1,3 @@ +#define char50_width 7 +#define char50_height 8 +static char char50_bits[] = {0x0, 0x0, 0x78, 0x44, 0x44, 0x78, 0x40, 0x40}; diff --git a/palmapple/fonts/char51.bmp b/palmapple/fonts/char51.bmp new file mode 100644 index 0000000..bffbcd6 --- /dev/null +++ b/palmapple/fonts/char51.bmp @@ -0,0 +1,3 @@ +#define char51_width 7 +#define char51_height 8 +static char char51_bits[] = {0x0, 0x0, 0x3c, 0x44, 0x44, 0x3c, 0x4, 0x4}; diff --git a/palmapple/fonts/char52.bmp b/palmapple/fonts/char52.bmp new file mode 100644 index 0000000..ab99578 --- /dev/null +++ b/palmapple/fonts/char52.bmp @@ -0,0 +1,3 @@ +#define char52_width 7 +#define char52_height 8 +static char char52_bits[] = {0x0, 0x0, 0x5c, 0x60, 0x40, 0x40, 0x40, 0x0}; diff --git a/palmapple/fonts/char53.bmp b/palmapple/fonts/char53.bmp new file mode 100644 index 0000000..e1064a4 --- /dev/null +++ b/palmapple/fonts/char53.bmp @@ -0,0 +1,3 @@ +#define char53_width 7 +#define char53_height 8 +static char char53_bits[] = {0x0, 0x0, 0x3c, 0x40, 0x38, 0x4, 0x78, 0x0}; diff --git a/palmapple/fonts/char54.bmp b/palmapple/fonts/char54.bmp new file mode 100644 index 0000000..39c7bc8 --- /dev/null +++ b/palmapple/fonts/char54.bmp @@ -0,0 +1,3 @@ +#define char54_width 7 +#define char54_height 8 +static char char54_bits[] = {0x20, 0x20, 0x78, 0x20, 0x20, 0x24, 0x18, 0x0}; diff --git a/palmapple/fonts/char55.bmp b/palmapple/fonts/char55.bmp new file mode 100644 index 0000000..26b4c87 --- /dev/null +++ b/palmapple/fonts/char55.bmp @@ -0,0 +1,3 @@ +#define char55_width 7 +#define char55_height 8 +static char char55_bits[] = {0x0, 0x0, 0x44, 0x44, 0x44, 0x4c, 0x34, 0x0}; diff --git a/palmapple/fonts/char56.bmp b/palmapple/fonts/char56.bmp new file mode 100644 index 0000000..0f51a42 --- /dev/null +++ b/palmapple/fonts/char56.bmp @@ -0,0 +1,3 @@ +#define char56_width 7 +#define char56_height 8 +static char char56_bits[] = {0x0, 0x0, 0x44, 0x44, 0x44, 0x28, 0x10, 0x0}; diff --git a/palmapple/fonts/char57.bmp b/palmapple/fonts/char57.bmp new file mode 100644 index 0000000..b469154 --- /dev/null +++ b/palmapple/fonts/char57.bmp @@ -0,0 +1,3 @@ +#define char57_width 7 +#define char57_height 8 +static char char57_bits[] = {0x0, 0x0, 0x44, 0x44, 0x54, 0x54, 0x6c, 0x0}; diff --git a/palmapple/fonts/char58.bmp b/palmapple/fonts/char58.bmp new file mode 100644 index 0000000..73c281d --- /dev/null +++ b/palmapple/fonts/char58.bmp @@ -0,0 +1,3 @@ +#define char58_width 7 +#define char58_height 8 +static char char58_bits[] = {0x0, 0x0, 0x44, 0x28, 0x10, 0x28, 0x44, 0x0}; diff --git a/palmapple/fonts/char59.bmp b/palmapple/fonts/char59.bmp new file mode 100644 index 0000000..804a574 --- /dev/null +++ b/palmapple/fonts/char59.bmp @@ -0,0 +1,3 @@ +#define char59_width 7 +#define char59_height 8 +static char char59_bits[] = {0x0, 0x0, 0x44, 0x44, 0x44, 0x3c, 0x4, 0x38}; diff --git a/palmapple/fonts/char5a.bmp b/palmapple/fonts/char5a.bmp new file mode 100644 index 0000000..1815337 --- /dev/null +++ b/palmapple/fonts/char5a.bmp @@ -0,0 +1,3 @@ +#define char5a_width 7 +#define char5a_height 8 +static char char5a_bits[] = {0x0, 0x0, 0x7c, 0x8, 0x10, 0x20, 0x7c, 0x0}; diff --git a/palmapple/fonts/char5b.bmp b/palmapple/fonts/char5b.bmp new file mode 100644 index 0000000..7103fcd --- /dev/null +++ b/palmapple/fonts/char5b.bmp @@ -0,0 +1,3 @@ +#define char5b_width 7 +#define char5b_height 8 +static char char5b_bits[] = {0x1c, 0x30, 0x30, 0x60, 0x30, 0x30, 0x1c, 0x0}; diff --git a/palmapple/fonts/char5c.bmp b/palmapple/fonts/char5c.bmp new file mode 100644 index 0000000..fa4894a --- /dev/null +++ b/palmapple/fonts/char5c.bmp @@ -0,0 +1,3 @@ +#define char5c_width 7 +#define char5c_height 8 +static char char5c_bits[] = {0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10}; diff --git a/palmapple/fonts/char5d.bmp b/palmapple/fonts/char5d.bmp new file mode 100644 index 0000000..2d48d04 --- /dev/null +++ b/palmapple/fonts/char5d.bmp @@ -0,0 +1,3 @@ +#define char5d_width 7 +#define char5d_height 8 +static char char5d_bits[] = {0x70, 0x18, 0x18, 0xc, 0x18, 0x18, 0x70, 0x0}; diff --git a/palmapple/fonts/char5e.bmp b/palmapple/fonts/char5e.bmp new file mode 100644 index 0000000..e4a71dd --- /dev/null +++ b/palmapple/fonts/char5e.bmp @@ -0,0 +1,3 @@ +#define char5e_width 7 +#define char5e_height 8 +static char char5e_bits[] = {0x30, 0x54, 0x18, 0x0, 0x0, 0x0, 0x0, 0x0}; diff --git a/palmapple/fonts/char5f.bmp b/palmapple/fonts/char5f.bmp new file mode 100644 index 0000000..b406f32 --- /dev/null +++ b/palmapple/fonts/char5f.bmp @@ -0,0 +1,3 @@ +#define char5f_width 7 +#define char5f_height 8 +static char char5f_bits[] = {0x0, 0x54, 0x28, 0x54, 0x28, 0x54, 0x0, 0x0}; diff --git a/palmapple/fonts/lowres.bmp b/palmapple/fonts/lowres.bmp new file mode 100644 index 0000000..11b5a17 --- /dev/null +++ b/palmapple/fonts/lowres.bmp @@ -0,0 +1,3 @@ +#define lowres_width 14 +#define lowres_height 16 +static unsigned char lowres_bits[] = {0xff, 0xfc, 0xff, 0xfc, 0xff, 0xfc, 0xff, 0xfc, 0xff, 0xfc, 0xff, 0xfc, 0xff, 0xfc, 0xff, 0xfc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; diff --git a/palmapple/iou.h b/palmapple/iou.h new file mode 100644 index 0000000..43c1ff9 --- /dev/null +++ b/palmapple/iou.h @@ -0,0 +1,113 @@ +#define KEYBOARD 0xC000 +#define CLR80STORE 0xC000 +#define SET80STORE 0xC001 +#define RDMAINRAM 0xC002 +#define RDCARDRAM 0xC003 +#define WRMAINRAM 0xC004 +#define WRCARDRAM 0xC005 +#define SETSLOTCXROM 0xC006 +#define SETINTCXROM 0xC007 +#define SETSTDZP 0xC008 +#define SETALTZP 0xC009 +#define SETINTC3ROM 0xC00A +#define SETSLOTC3ROM 0xC00B +#define CLR80VID 0xC00C +#define SET80VID 0xC00D +#define CLRALTCHAR 0xC00E +#define SETALTCHAR 0xC00F + +#define KBDSTRB 0xC010 +#define RDLCBNK2 0xC011 +#define RDLCRAM 0xC012 +#define RDRAMRD 0xC013 +#define RDRAMWRT 0xC014 +#define RDCXROM 0xC015 +#define RDALTZP 0xC016 +#define RDC3ROM 0xC017 +#define RD80STORE 0xC018 +#define RDVBLBAR 0xC019 +#define RDTEXT 0xC01A +#define RDMIXED 0xC01B +#define RDPAGE2 0xC01C +#define RDHIRES 0xC01D +#define RDALTCHAR 0xC01E +#define RD80COL 0xC01F + +#define TAPEOUT 0xC020 +#define PRNTOUT 0xC021 /* Virtual printer */ +#define SPKR 0xC030 + +#define TXTCLR 0xC050 +#define TXTSET 0xC051 +#define MIXCLR 0xC052 +#define MIXSET 0xC053 +#define LOWSCR 0xC054 +#define HISCR 0xC055 +#define LOWRES 0xC056 +#define HIRES 0xC057 +#define CLRAN0 0xC058 +#define SETAN0 0xC059 +#define CLRAN1 0xC05A +#define SETAN1 0xC05B +#define CLRAN2 0xC05C +#define SETAN2 0xC05D +#define CLRAN3 0xC05E +#define SETDHIRES 0xC05E +#define SETAN3 0xC05F +#define CLRDHIRES 0xC05F + +#define TAPEIN 0xC060 +#define BUTN0 0xC061 +#define BUTN1 0xC062 +#define BUTN2 0xC063 +#define PADDL0 0xC064 +#define PADDL1 0xC065 +#define PADDL2 0xC066 +#define PADDL3 0xC067 + +#define PTRIG 0xC070 +#define SETIOUDIS 0xC07E +#define RDIOUDIS 0xC07E +#define CLRIOUDIS 0xC07F +#define RDDHIRES 0xC07F + +#define CLRROM 0xCFFF + +/* LSB are graphics switches */ +#define SS_TEXT (1<<0) +#define SS_MIXED (1<<1) +#define SS_PAGE2 (1<<2) +#define SS_HIRES (1<<3) +#define SS_80COL (1<<4) +#define SS_DHIRES (1<<5) +#define SS_80STORE (1<<6) +#define IOU_VIDEO_SS_MASK (0x7f) + +#define SS_ALTCHAR (1<<7) +#define SS_RAMRD (1<<8) +#define SS_RAMWRT (1<<9) +#define SS_SLOTCXROM (1<<10) +#define SS_ALTZP (1<<11) +#define SS_SLOTC3ROM (1<<12) +#define SS_IOUDIS (1<<13) +#define SS_LCBNK2 (1<<14) +#define SS_LCRAMRD (1<<15) +#define SS_LCRAM SS_LCRAMRD + +/* #define SS_LCRAMWRT (1<<16) */ +/* #define SS_VBLBAR (1<<17) */ +/* #define SS_EXPNROM (1<<18) 80 column ROM $C800-$CFFF active */ + +/* #define SS_AN0 (1<<19) */ +/* #define SS_AN1 (1<<20) */ +/* #define SS_AN2 (1<<21) */ +/* #define SS_AN3 (1<<22) */ + +#define SS_LCRAMWRT (1<<1) +#define SS_VBLBAR (1<<2) +#define SS_EXPNROM (1<<3) /* 80 column ROM $C800-$CFFF active */ + +#define SS_AN0 (1<<4) +#define SS_AN1 (1<<5) +#define SS_AN2 (1<<6) +#define SS_AN3 (1<<7) diff --git a/palmapple/memory.c b/palmapple/memory.c new file mode 100644 index 0000000..0148a04 --- /dev/null +++ b/palmapple/memory.c @@ -0,0 +1,899 @@ +#include "6502.h" +#include "memory.h" +#include "iou.h" + +#define LOW_BYTE 1 +#define HIGH_BYTE 0 + +#define SET(x, y) IOUState[y] = (IOUSoftSwitch[y] = IOUSoftSwitch[y] | (x)) +#define RESET(x, y) IOUState[y] = (IOUSoftSwitch[y] = IOUSoftSwitch[y] &~ (x)) + +UInt8 *AppleMemory; +UInt8 *AuxMemory; +UInt8 *TempMemory; +UInt8 *AppleROM; +extern union PCStruct Address; + +extern UInt8 *address_line[0x700]; +extern char *AppleFontBitmap; + +extern BOOL LOOP; +extern BOOL QUIT; +BOOL LOOP1 = 1; + +extern UInt16 AppleClock; +extern UInt16 DiskOffset; +UInt16 LastAppleClock = 0; + +UInt8 BootROM[256]; +UInt8 BootImage[256]; + +UInt8 SlotROMStatus = 0; +UInt8 LastKey = 0; +UInt16 IOUSoftSwitch[2] = {0, 0}; +UInt16 IOUState[2] = {0, 0}; + +UInt8 address_latch, data_latch, C800ROMSlot; + +EventType event; + +/* Apple IO Read */ +UInt8 RIOM(); + +/* SLOT 5 IO Read */ +UInt8 SLT5(); + +/* SLOT 6 IO Read */ +UInt8 SLT6(); + +/* Apple IO Write */ +void WIOM(UInt8 value); + +/* Screen Write */ +void WSCM(UInt8 value); + +/* Protect ROM */ +void READONLY(UInt8 value); + +/* Aux Memory Read Write */ +UInt8 AuxRead(); +void AuxWrite(UInt8 value); + +UInt8 REXP(); + +UInt8 RC3M(); + +void LoadROM(); + +void toggleLanguageCard(); + +#define NO_OF_PHASES 8 +#define MAX_PHYSICAL_TRACK_NO (40*NO_OF_PHASES) +#define RAW_TRACK_BYTES 6392 + +static Int8 stepper_movement_table[16][NO_OF_PHASES] = { + { 0, 0, 0, 0, 0, 0, 0, 0 }, /* all electromagnets off */ + { 0, -1, -2, -3, 0, 3, 2, 1 }, /* EM 1 on */ + { 2, 1, 0, -1, -2, -3, 0, 3 }, /* EM 2 on */ + { 1, 0, -1, -2, -3, 0, 3, 2 }, /* EMs 1 & 2 on */ + { 0, 3, 2, 1, 0, -1, -2, -3 }, /* EM 3 on */ + { 0, -1, 0, 1, 0, -1, 0, 1 }, /* EMs 1 & 3 on */ + { 3, 2, 1, 0, -1, -2, -3, 0 }, /* EMs 2 & 3 on */ + { 2, 1, 0, -1, -2, -3, 0, 3 }, /* EMs 1, 2 & 3 on */ + { -2, -3, 0, 3, 2, 1, 0, -1 }, /* EM 4 on */ + { -1, -2, -3, 0, 3, 2, 1, 0 }, /* EMs 1 & 4 on */ + { 0, 1, 0, -1, 0, 1, 0, -1 }, /* EMs 2 & 4 */ + { 0, -1, -2, -3, 0, 3, 2, 1 }, /* EMs 1, 2 & 4 on */ + { -3, 0, 3, 2, 1, 0, -1, -2 }, /* EMs 3 & 4 on */ + { -2, -3, 0, 3, 2, 1, 0, -1 }, /* EMs 1, 3 & 4 on */ + { 0, 3, 2, 1, 0, -1, -2, -3 }, /* EMs 2, 3 & 4 on */ + { 0, 0, 0, 0, 0, 0, 0, 0 } }; /* all electromagnets on */ + +static DmOpenRef diskimage; +UInt16 motor_on; +static Int16 physical_track_no; +static Int16 stepper_status; +static UInt16 read_count = 0; +static Int8 track_buffer_valid=0; +static Int8 track_buffer_dirty=0; +static Int8 track_buffer_track=0; +static Int8 write_mode; +static Int16 last_track = -1; +static UInt8 nibble[RAW_TRACK_BYTES]; +static UInt16 position; +static UInt8 write_protect; +static DmOpenRef romDB; +static UInt8* values; +static MemHandle value; +static LocalID rom; + +UInt8 logical_track; + +void toggleStepper(); +void toggleMotor(); +UInt8 read_nibble(); +void load_track_buffer(void); +int mount_disk( int slot, int drive ); + +/* Read Operation of Memory Page Mapping */ +READBYTE ReadFunction[256] = { + /* 0 1 2 3 4 5 6 7 8 9 A B C D E F*/ + /* 00 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + /* 10 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + /* 20 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + /* 30 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + + /* 40 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + /* 50 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + /* 60 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + /* 70 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + + /* 80 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + /* 90 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + /* A0 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + /* B0 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + + /* C0 */ RIOM, NULL, NULL, RC3M, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + /* D0 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + /* E0 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + /* F0 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, +}; + +WRITEBYTE WriteFunction[256] = { + /* 0 1 2 3 4 5 6 7 8 9 A B C D E F*/ + /* 00 */ NULL, NULL, NULL, NULL, WSCM, WSCM, WSCM, WSCM, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + /* 10 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + /* 20 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + /* 30 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + + /* 40 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + /* 50 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + /* 60 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + /* 70 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + + /* 80 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + /* 90 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + /* A0 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + /* B0 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + + /* C0 */ WIOM, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + /* D0 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + /* E0 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + /* F0 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, +}; + +void init_memory(void) { + FtrPtrNew('Pala', 0, 65536, (void**) &AppleMemory); + MemSet(AppleMemory, 65535, 0); + + FtrPtrNew('Pala', 1, 65536, (void**) &AuxMemory); + MemSet(AuxMemory, 65535, 0); + + FtrPtrNew('Pala', 2, 4096, (void**) &TempMemory); + MemSet(TempMemory, 4096, 0); + + LoadROM(); + + { + UInt16 count; + + for (count = 0xD0; count < 0x100; count++) { + WriteFunction[count] = READONLY; + } + } + + C800ROMSlot = 0; +} + +void LoadROM(void) { + DmOpenRef romDB; + LocalID romID; + MemHandle romRec; + UInt8* roms; + UInt32 romStart, memStart; + MemHandle handle; + + romID = DmFindDatabase(0, "apple2e.rom"); + + romDB = DmOpenDatabase(0, romID, dmModeReadOnly); + + romRec = DmQueryRecord(romDB, 0); + + roms = (UInt8 *) MemHandleLock(romRec); + + romStart = 0x004100; memStart = 0x00C100; + + handle = MemHandleNew(0x3F00); + AppleROM = (UInt8*) MemHandleLock(handle); + + MemMove(AppleMemory + memStart, roms + romStart, 0x3F00); + MemMove(AppleROM, roms + romStart, 0x3F00); + + MemHandleUnlock(romRec); + DmCloseDatabase(romDB); + + romID = DmFindDatabase(0, "slot6.rom"); + + romDB = DmOpenDatabase(0, romID, dmModeReadOnly); + + romRec = DmQueryRecord(romDB, 0); + + roms = (UInt8 *) MemHandleLock(romRec); + + MemMove(BootROM, roms, 256); + + MemHandleUnlock(romRec); + DmCloseDatabase(romDB); + + physical_track_no = 0; + + mount_disk(6, 0); + + position = 0; last_track = -1; + + BootROM[0x004C] = 0xA9; + BootROM[0x004D] = 0x00; + BootROM[0x004E] = 0xEA; + +} + +/* Apple ROM Paging */ +UInt8 RRMP() { + return 0x00; +} + +UInt8 readKey() { + + if (EvtEventAvail()) { + EvtGetEvent(&event, 0); + SysHandleEvent(&event); + if (event.eType == appStopEvent) { + QUIT = 0; + return LastKey; + } + if (event.eType == keyDownEvent) { + UInt8 key; + key = (event.data.keyDown.chr == 10 ? 13 : event.data.keyDown.chr) | 0x80; + // if (event.data.keyDown.chr == 10) LOOP = 0; + return key; + } + } + + return LastKey; +} + +/* Apple Soft Switch Read */ +UInt8 readSoftSwitch() +{ + UInt16 flag; + UInt8 data; + + static UInt16 soft_switch_list[16] = { + 0 /* key strobe */, SS_LCBNK2, SS_LCRAM, SS_RAMRD, + SS_RAMWRT, SS_SLOTCXROM, SS_ALTZP, SS_SLOTC3ROM, + SS_80STORE, 0 /* VBL */, SS_TEXT, SS_MIXED, + SS_PAGE2, SS_HIRES, SS_ALTCHAR, SS_80COL }; + + data = 0; + flag = soft_switch_list[Address.Byte[LOW_BYTE] & 0x0F]; + + if (flag) { + data = (flag & IOUSoftSwitch[0])? data | 0x80 : data & 0x7f; + } else { + if (Address.PC == KBDSTRB) { + LastKey &= 0x7F; + + LastKey = readKey(); + + return LastKey; + } else if (Address.PC == RDVBLBAR) { + data = (SS_VBLBAR & IOUSoftSwitch[1])? data | 0x80 : data & 0x7f; + } + } + return data; +} + +UInt8 REXP() { + if (!(IOUState[0] & SS_SLOTCXROM) && Address.PC == 0xCFFF) { + // MemMove(AppleMemory + 0xCD00, BootROM, 256); + MemMove(AppleMemory + 0xCE00, BootROM, 256); + RESET(SS_EXPNROM, 1); + return 0x00; + } else { + return AppleMemory[Address.PC]; + } +} + +UInt8 RC3M() { + if (!(IOUSoftSwitch[0] & SS_SLOTC3ROM)) { + if (C800ROMSlot == 0) { + C800ROMSlot = 3; + SET(SS_EXPNROM, 1); + } + MemMove(AppleMemory + 0xC800, AppleROM + 0x700, 2048); + } + + return AppleMemory[Address.PC]; +} + +void toggleVideoSoftSwitch() { + UInt8 vswitch = Address.Byte[LOW_BYTE] & 0x0F; + + switch (vswitch) { + case 0x00: + RESET(SS_TEXT, 0); + break; + case 0x01: + SET(SS_TEXT, 0); + RESET(SS_HIRES, 0); + break; + case 0x04: + if (IOUSoftSwitch[0] & SS_PAGE2){ + RESET(SS_PAGE2, 0); + if (IOUSoftSwitch[0] & SS_80STORE) { + ReadFunction[0x04] = NULL; + ReadFunction[0x05] = NULL; + ReadFunction[0x06] = NULL; + ReadFunction[0x07] = NULL; + WriteFunction[0x04] = NULL; + WriteFunction[0x05] = NULL; + WriteFunction[0x06] = NULL; + WriteFunction[0x07] = NULL; + } + } + break; + case 0x05: + if (!(IOUSoftSwitch[0] & SS_PAGE2)){ + SET(SS_PAGE2, 0); + if (IOUSoftSwitch[0] & SS_80STORE) { + ReadFunction[0x04] = RRMP; + ReadFunction[0x05] = RRMP; + ReadFunction[0x06] = RRMP; + ReadFunction[0x07] = RRMP; + WriteFunction[0x04] = READONLY; + WriteFunction[0x05] = READONLY; + WriteFunction[0x06] = READONLY; + WriteFunction[0x07] = READONLY; + } + } + break; + case 0x06: + if (IOUSoftSwitch[0] & SS_HIRES) + RESET(SS_HIRES, 0); + break; + case 0x07: + if (!(IOUSoftSwitch[0] & SS_HIRES)) { + SET(SS_HIRES, 0); + RESET(SS_TEXT, 0); + } + break; + } +} + +void toggleMemorySoftSwitch(UInt8 data) { + UInt8 Page; + + switch (Address.PC) { + case SETSLOTCXROM: + RESET(SS_SLOTCXROM, 0); + for (Page = 0xC1; Page < 0xC8; Page++) if (Page != 0xC3) ReadFunction[Page] = RRMP; + MemSet(AppleMemory + 0xC100, 512, 0); + MemSet(AppleMemory + 0xC400, 1024, 0); + ReadFunction[0xC6] = NULL; + MemMove(AppleMemory + 0x00C600, BootROM, 256); + break; + case SETINTCXROM: + SET(SS_SLOTCXROM, 0); + for (Page = 0xC1; Page < 0xC8; Page++) if (Page != 0xC3) ReadFunction[Page] = NULL; + MemMove(AppleMemory + 0xC100, AppleROM, 512); + MemMove(AppleMemory + 0xC400, AppleROM + 0x300, 1024); + break; + case SETSTDZP: + break; + case SETALTZP: + break; + case SETINTC3ROM: + MemMove(AppleMemory + 0xC300, AppleROM + 0x200, 256); + SET(SS_SLOTC3ROM, 0); + break; + case SETSLOTC3ROM: + MemSet(AppleMemory + 0xC300, 256, 0); + RESET(SS_SLOTC3ROM, 0); + break; + case RDMAINRAM: + if (IOUSoftSwitch[0] & SS_RAMRD){ + RESET(SS_RAMRD, 0); + } + break; + case RDCARDRAM: + SET(SS_RAMRD, 0); + break; + case WRMAINRAM: + RESET(SS_RAMWRT, 0); + break; + case WRCARDRAM: + SET(SS_RAMWRT, 0); + break; + case CLR80STORE: + if (IOUSoftSwitch[0] & SS_80STORE) { + RESET(SS_80STORE, 0); + } + break; + case SET80STORE: + if (!(IOUSoftSwitch[0] & SS_80STORE)) { + SET(SS_80STORE, 0); + } + break; + } + + if (IOUState[0] & SS_RAMRD) { + UInt16 Page; + for (Page = 0x02; Page < 0xC0; Page++) ReadFunction[Page] = RRMP; + } else { + UInt16 Page; + for (Page = 0x02; Page < 0xC0; Page++) ReadFunction[Page] = NULL; + } + + + if (IOUState[0] & SS_RAMWRT) { + UInt16 Page; + for (Page = 0x02; Page < 0xC0; Page++) WriteFunction[Page] = READONLY; + } else { + UInt16 Page; + for (Page = 0x02; Page < 0xC0; Page++) WriteFunction[Page] = NULL; + } +} + +/* Apple IO Read */ +UInt8 RIOM() { + UInt8 value, soft; + + value = 0x00; + // soft = (UInt8) (Address.Byte[LOW_BYTE] & (UInt8) (0xF0)); + + switch (Address.Byte[LOW_BYTE]) { + case 0x00: case 0x01: case 0x02: case 0x03: + case 0x04: case 0x05: case 0x06: case 0x07: + case 0x08: case 0x09: case 0x0A: case 0x0B: + case 0x0C: case 0x0D: case 0x0E: case 0x0F: + LastKey = readKey(); + value = LastKey; + break; + case 0x10: case 0x11: case 0x12: case 0x13: + case 0x14: case 0x15: case 0x16: case 0x17: + case 0x18: case 0x19: case 0x1A: case 0x1B: + case 0x1C: case 0x1D: case 0x1E: case 0x1F: + value = readSoftSwitch(); + break; + case 0x20: case 0x21: case 0x22: case 0x23: + case 0x24: case 0x25: case 0x26: case 0x27: + case 0x28: case 0x29: case 0x2A: case 0x2B: + case 0x2C: case 0x2D: case 0x2E: case 0x2F: + + case 0x30: case 0x31: case 0x32: case 0x33: + case 0x34: case 0x35: case 0x36: case 0x37: + case 0x38: case 0x39: case 0x3A: case 0x3B: + case 0x3C: case 0x3D: case 0x3E: case 0x3F: + + case 0x40: case 0x41: case 0x42: case 0x43: + case 0x44: case 0x45: case 0x46: case 0x47: + case 0x48: case 0x49: case 0x4A: case 0x4B: + case 0x4C: case 0x4D: case 0x4E: case 0x4F: + + break; + case 0x50: case 0x51: case 0x52: case 0x53: + case 0x54: case 0x55: case 0x56: case 0x57: + case 0x58: case 0x59: case 0x5A: case 0x5B: + case 0x5C: case 0x5D: case 0x5E: case 0x5F: + toggleVideoSoftSwitch(); + break; + case 0x60: case 0x61: case 0x62: case 0x63: + case 0x64: case 0x65: case 0x66: case 0x67: + case 0x68: case 0x69: case 0x6A: case 0x6B: + case 0x6C: case 0x6D: case 0x6E: case 0x6F: + + case 0x70: case 0x71: case 0x72: case 0x73: + case 0x74: case 0x75: case 0x76: case 0x77: + case 0x78: case 0x79: case 0x7A: case 0x7B: + case 0x7C: case 0x7D: case 0x7E: case 0x7F: + + break; + /* Slot 0 */ + case 0x80: case 0x81: case 0x82: case 0x83: + case 0x84: case 0x85: case 0x86: case 0x87: + case 0x88: case 0x89: case 0x8A: case 0x8B: + case 0x8C: case 0x8D: case 0x8E: case 0x8F: + toggleLanguageCard(); + break; + /* Slot 1 */ + case 0x90: case 0x91: case 0x92: case 0x93: + case 0x94: case 0x95: case 0x96: case 0x97: + case 0x98: case 0x99: case 0x9A: case 0x9B: + case 0x9C: case 0x9D: case 0x9E: case 0x9F: + break; + /* Slot 2 */ + case 0xA0: case 0xA1: case 0xA2: case 0xA3: + case 0xA4: case 0xA5: case 0xA6: case 0xA7: + case 0xA8: case 0xA9: case 0xAA: case 0xAB: + case 0xAC: case 0xAD: case 0xAE: case 0xAF: + break; + /* Slot 3 */ + case 0xB0: case 0xB1: case 0xB2: case 0xB3: + case 0xB4: case 0xB5: case 0xB6: case 0xB7: + case 0xB8: case 0xB9: case 0xBA: case 0xBB: + case 0xBC: case 0xBD: case 0xBE: case 0xBF: + break; + /* Slot 4 */ + case 0xC0: case 0xC1: case 0xC2: case 0xC3: + case 0xC4: case 0xC5: case 0xC6: case 0xC7: + case 0xC8: case 0xC9: case 0xCA: case 0xCB: + case 0xCC: case 0xCD: case 0xCE: case 0xCF: + break; + /* Slot 5 */ + case 0xD0: case 0xD1: case 0xD2: case 0xD3: + case 0xD4: case 0xD5: case 0xD6: case 0xD7: + case 0xD8: case 0xD9: case 0xDA: case 0xDB: + case 0xDC: case 0xDD: case 0xDE: case 0xDF: + break; + /* Slot 6 */ + case 0xEC: +/* if ( address_latch == 0x0E ) */ +/* write_mode = 0; */ +/* else if ( address_latch == 0x0F ) */ +/* write_mode = 1; */ + +/* if ( !write_mode ) */ + +/* value = read_nibble(); */ + +/* AppleMemory[Address.PC] = value; */ + + value = nibble[position++]; + + if ( position >= RAW_TRACK_BYTES ) position = 0; + + address_latch = 0x0C; + break; + case 0xED: + address_latch = 0x0D; + break; + case 0xEE: + address_latch = 0x0E; + if ( address_latch == 0x0D ) /* check write protect */ + value = 0xFF; + break; + case 0xEF: + address_latch = 0x0F; + break; + case 0xE8: /* motor off */ + case 0xE9: /* motor on */ + toggleMotor(); + break; + case 0xEA: /* select driver 1 */ + case 0xEB: /* select driver 2 */ + break; + /* C0X0-C0X7, stepper toggle */ + case 0xE0: case 0xE1: case 0xE2: case 0xE3: + case 0xE4: case 0xE5: case 0xE6: case 0xE7: + toggleStepper( ); + break; + /* Slot 7 */ + case 0xF0: case 0xF1: case 0xF2: case 0xF3: + case 0xF4: case 0xF5: case 0xF6: case 0xF7: + case 0xF8: case 0xF9: case 0xFA: case 0xFB: + case 0xFC: case 0xFD: case 0xFE: case 0xFF: + break; + } + + return value; +} + +/* SLOT 5 IO Read */ +UInt8 SLT5() { + Char buf[20]; + StrPrintF(buf, "Boot : %4X", Address.PC); + WinDrawChars(buf, StrLen(buf), 50, 0); + return BootROM[Address.Byte[LOW_BYTE]]; +} + +/* SLOT 6 IO Read */ +UInt8 SLT6() { + Char buf[20]; + StrPrintF(buf, "Boot : %4X", Address.PC); + WinDrawChars(buf, StrLen(buf), 50, 0); + return BootROM[Address.Byte[LOW_BYTE]]; +} + +/* Apple IO Write */ +void WIOM(UInt8 value) { + AppleMemory[Address.PC] = value; + + switch ((UInt8) (Address.Byte[LOW_BYTE] & (UInt8) (0xF0))) { + case 0x00: + toggleMemorySoftSwitch(value); +/* HostTraceOutputTL(sysErrorClass, "Write Soft Card : %X %X", Address.PC, value); */ + break; + case 0x10: + if (Address.PC == KBDSTRB) + LastKey &= 0x7F; + break; + case 0x20: case 0x30: case 0x40: + break; + case 0x50: + toggleVideoSoftSwitch(); +/* HostTraceOutputTL(sysErrorClass, "Write Video Card : %X", Address.PC); */ + break; + case 0x60: case 0x70: + break; + case 0x80: /* Slot 0 */ + toggleLanguageCard(); +/* HostTraceOutputTL(sysErrorClass, "Write Language Card : %X %X", Address.PC, value); */ + break; + case 0x90: /* Slot 1 */ + break; + case 0xA0: /* Slot 2 */ + break; + case 0xB0: /* Slot 3 */ + break; + case 0xC0: /* Slot 4 */ + break; + case 0xD0: /* Slot 5 */ + break; + case 0xE0: /* Slot 6 */ + switch ((UInt8) (Address.Byte[LOW_BYTE] & (UInt8) (0x0F))) { + case 0x0C: + if ( address_latch == 0x0E ) + write_mode = 0; + else if ( address_latch == 0x0F ) + write_mode = 1; + address_latch = 0x0C; + return; + case 0x0D: + address_latch = 0x0D; + break; + case 0x0E: + if ( address_latch == 0x0D ) { /* check write protect */ + address_latch = 0x0E; + return; + } + address_latch = 0x0E; + break; + case 0x0F: + address_latch = 0x0F; + break; + case 0x08: /* motor off */ + case 0x09: /* motor on */ + toggleMotor(); + break; + case 0x0A: /* select driver 1 */ + case 0x0B: /* select driver 2 */ + break; + default: /* C0X0-C0X7, stepper toggle */ + toggleStepper( ); + break; + } + } +} + +UInt8 AuxRead() { + UInt8 value; + if ((IOUState[0] & SS_LCRAMRD)) + value = AuxMemory[Address.PC - ((!(IOUState[0] & SS_LCBNK2) && Address.PC < 0xE000) ? 0x1000 : 0x000)]; + else + value = AppleMemory[Address.PC]; + + return value; +} + +void AuxWrite(UInt8 value) { + AuxMemory[Address.PC - ((!(IOUState[0] & SS_LCBNK2) && Address.PC < 0xE000) ? 0x1000 : 0x000)] = value; + AppleMemory[Address.PC] = value; +} + +void READONLY(UInt8 data) { + return; +} + +/* Screen Write */ +void WSCM(UInt8 data) { + AppleMemory[Address.PC] = data; + + /* + { + UInt8 *line, value; + UInt16 count, count1, count2, value1; + + value = data; + if (value < 0xE0) value &= 0x3F; + if (value >= 0xE0) value = value - 0xA0; + count1 = value << 3; count2 = count1 + 8; + if ((Address.PC - 0x400) < 0x800) { + line = address_line[Address.PC - 0x400]; + value1 = 0; + for (count = count1; count < count2; count++) { + line[value1] = ~AppleFontBitmap[count]; + value1 += 40; + } + } + } + */ +} + +void toggleStepper() +{ + register Int16 magnet, on, old_track_no, new_status,phase; + + magnet = (Address.Byte[LOW_BYTE] & 0x0E) >> 1; + on = Address.Byte[LOW_BYTE] & 0x01; + old_track_no = physical_track_no; + if ( on ) + stepper_status |= (1<= MAX_PHYSICAL_TRACK_NO ) + physical_track_no = MAX_PHYSICAL_TRACK_NO-1; + track_buffer_valid = 0; + } + + if ( !track_buffer_valid ) { + load_track_buffer(); + } +} + +void toggleMotor( ) +{ + int on; + + on = Address.Byte[LOW_BYTE] & 0x01; + + if ( motor_on != on ) { + WinDrawChars("I", 1, 10, 150); + motor_on = on; + } else { + WinDrawChars(" ", 1, 10, 150); + } + +} + +UInt8 read_nibble() +{ + UInt8 data; + + if ( !track_buffer_valid ) { + load_track_buffer(); + } + + data = nibble[position++]; + + if ( position >= RAW_TRACK_BYTES ) position = 0; + + return data; +} + +int mount_disk( int slot, int drive ) +{ + write_protect = 0; + + rom = DmFindDatabase(0, "prodos.dsk"); + diskimage = DmOpenDatabase(0, rom, dmModeReadOnly); + + load_track_buffer(); + + return 0; +} + +void load_track_buffer(void) +{ + Char test[20]; + + logical_track = (physical_track_no + 1) >> 2; + + if (logical_track == last_track) { + position = 0; + track_buffer_track = physical_track_no; + track_buffer_dirty = 0; + track_buffer_valid = 1; + return; + } + + last_track = logical_track; + + StrPrintF(test, "Track : %d ", logical_track); + WinDrawChars(test, StrLen(test), 50, 150); + + value = DmQueryRecord(diskimage, logical_track); + values = (UInt8 *) MemHandleLock(value); + + MemMove(nibble, values, 6392); + + track_buffer_track = physical_track_no; + track_buffer_dirty = 0; + track_buffer_valid = 1; + + position = 0; + + MemHandleUnlock(value); +} + +void toggleLanguageCard( ) +{ +/* UInt8 old_ss, old_ss1; */ + +/* old_ss = IOUSoftSwitch[0]; */ +/* old_ss1 = IOUSoftSwitch[1]; */ + + /* set IOU soft switches */ + switch(Address.Byte[LOW_BYTE] & 0x0F){ + case 0: + SET(SS_LCBNK2, 0); + SET(SS_LCRAMRD, 0); + RESET(SS_LCRAMWRT, 1); + break; + case 1: + SET(SS_LCBNK2, 0); + RESET(SS_LCRAMRD, 0); + SET(SS_LCRAMWRT, 1); + break; + case 2: + SET(SS_LCBNK2, 0); + RESET(SS_LCRAMRD, 0); + RESET(SS_LCRAMWRT, 1); + break; + case 3: + SET(SS_LCBNK2, 0); + SET(SS_LCRAMRD, 0); + SET(SS_LCRAMWRT, 1); + break; + case 8: + RESET(SS_LCBNK2, 0); + SET(SS_LCRAMRD, 0); + RESET(SS_LCRAMWRT, 1); + break; + case 9: + RESET(SS_LCBNK2, 0); + RESET(SS_LCRAMRD, 0); + SET(SS_LCRAMWRT, 1); + break; + case 0xA: + RESET(SS_LCBNK2, 0); + RESET(SS_LCRAMRD, 0); + RESET(SS_LCRAMWRT, 1); + break; + case 0xB: + RESET(SS_LCBNK2, 0); + SET(SS_LCRAMRD, 0); + SET(SS_LCRAMWRT, 1); + } + + if ((IOUState[1] & SS_LCRAMWRT)) { + UInt16 Page; + for (Page = 0xD0; Page <= 0xFF; Page++) WriteFunction[Page] = AuxWrite; + } else { + UInt16 Page; + for (Page = 0xD0; Page <= 0xFF; Page++) WriteFunction[Page] = READONLY; + } + + if ((IOUState[0] & SS_LCRAMRD)) { + UInt16 Page; + + MemMove(AppleMemory + 0xD000, AuxMemory + 0xD000 - (!(IOUState[0] & SS_LCBNK2) ? 0x1000 : 0x000), 4096); + + MemMove(AppleMemory + 0xE000, AuxMemory + 0xE000, 8192); + + for (Page = 0xD0; Page <= 0xFF; Page++) ReadFunction[Page] = NULL; + } else { + UInt16 Page; + + MemMove(AppleMemory + 0xD000, AppleROM + 0xD000 - 0xC100, 4096); + MemMove(AppleMemory + 0xE000, AppleROM + 0xE000 - 0xC100, 8192); + + for (Page = 0xD0; Page <= 0xFF; Page++) ReadFunction[Page] = NULL; + } +} diff --git a/palmapple/memory.h b/palmapple/memory.h new file mode 100644 index 0000000..c82de45 --- /dev/null +++ b/palmapple/memory.h @@ -0,0 +1,2 @@ +typedef UInt8 (*READBYTE)(void); +typedef void (*WRITEBYTE)(UInt8 value); diff --git a/palmapple/palmapple.c b/palmapple/palmapple.c new file mode 100644 index 0000000..161f6a3 --- /dev/null +++ b/palmapple/palmapple.c @@ -0,0 +1,164 @@ +// 6502 is Little Endian -- Least Signature Byte First +// ++++++++++++++++++++++++++++++++++++ +// | Address 1 | Address 0 | +// ++++++++++++++++++++++++++++++++++++ +// | High Byte | Low Byte | +// ++++++++++++++++++++++++++++++++++++ +// +// Dragon Ball is Big Endian -- Most Signature Byte First +// ++++++++++++++++++++++++++++++++++++ +// | Address 0 | Address 1 | +// ++++++++++++++++++++++++++++++++++++ +// | High Byte | Low Byte | +// ++++++++++++++++++++++++++++++++++++ + +#include +#include +#include + +#define TRUE 1 +#define FALSE 0 + +static int StartApplication(void); +static void EventLoop(void); +static FormType *mainForm; + +UInt16 refNum; + +void init_memory(); +void init_6502(); + +void switchHRMode(void); +void switchNormalMode(void); + +UInt16 buffer1[16] = {0xF1, 0xF2, 0xF1, 0xF2,0xF1, 0xF2, 0xF1, 0xF2, 0xF1, 0xF2, 0xF1, 0xF2,0xF1, 0xF2, 0xF1, 0xF2,}; + +union PCStruct { + UInt8 Byte[2]; + UInt16 PC; +}; + +DWord PilotMain (Word cmd, Ptr cmdPBP, Word launchFlags) +{ + int error; + + if (cmd == sysAppLaunchCmdNormalLaunch) { + +#ifdef DEBUG + HostTraceInit(); +#endif + + MemSemaphoreReserve(TRUE); + + error = StartApplication(); + if (error) return error; + + EventLoop(); + +#ifdef SONY + switchNormalMode(); +#endif + + FtrPtrFree('Pala', 0); + + MemSemaphoreRelease(FALSE); + +#ifdef DEBUG + HostTraceClose(); +#endif + + } + + return 0; +} + +void switchHRMode(void) { + Err error; + UInt32 width, height, depth; + + error = HROpen(refNum); + if (!error) { + width = hrWidth; height = hrHeight; depth = 8; + + error = HRWinScreenMode(refNum, winScreenModeSet, &width, &height, &depth, NULL); + if (error == errNone) { + } + } + +} + +void switchNormalMode(void) { + Err error; + + error = HRWinScreenMode ( refNum, winScreenModeSetToDefaults, NULL, NULL, NULL, NULL ); + if ( error != errNone ){ + + } else { + + } + + error = HRClose(refNum); +} + +static int StartApplication(void) +{ +#ifdef SONY + SonySysFtrSysInfoP sonySysFtrSysInfoP; + Err error = 0; + + if ((error = FtrGet(sonySysFtrCreator, sonySysFtrNumSysInfoP, (UInt32*)&sonySysFtrSysInfoP))) { + + } else { + if (sonySysFtrSysInfoP->libr & sonySysFtrSysInfoLibrHR) { + if ((error = SysLibFind(sonySysLibNameHR, &refNum))){ + if (error == sysErrLibNotFound) { + error = SysLibLoad('libr', sonySysFileCHRLib, &refNum ); + } + } + } + } + + switchHRMode(); +#endif + + mainForm = FrmNewForm(0, "AppleIIe", 0, 0, 160, 160, FALSE, 0, 0, 0); + + init_memory(); + init_6502(); + + FrmDrawForm(mainForm); + GsiInitialize(); + GsiSetLocation(0, 150); + GsiEnable(true); + + return 0; +} + +static void EventLoop(void) +{ + short err; + int formID, count = 0, count1 = 0; + UInt8* pointer; + FormPtr form; + EventType event; + unsigned sigcode; + + EvtGetEvent(&event, 0); + if (!SysHandleEvent(&event)) { + if (event.eType == frmLoadEvent) { + form = FrmInitForm(0); + FrmSetActiveForm(form); + } + if (event.eType == appStopEvent) return; + } + + run_6502(); + +/* do { */ +/* EvtGetEvent(&event, -1); */ +/* if (SysHandleEvent(&event)) continue; */ + +/* FrmDispatchEvent(&event); */ +/* } while (event.eType != appStopEvent); */ + +} diff --git a/readme b/readme new file mode 100755 index 0000000..a64ddb3 --- /dev/null +++ b/readme @@ -0,0 +1,85 @@ + Welcome to the Apple ][ emulator for Palm PDAs. + +Authors: +Hilary Cheng : hilarycheng@yahoo.com +David Schmenk: lematinracing@yahoo.com + +Web Sites : http://sf.net/projects/palmapple +Public Forum : http://sf.net/forum/forum.php?forum_id=88936 + +License: +Appalm][ Licenses is GNU GPL. Please go to this links for more +details Appalm][ is based on YAE so that we can port to PalmOS +Platform. Appalm][ cannot be used for sale or any redistribution +unless there is an agreement with the authors. Please contact +the author before any sale or any redistribution. + +Appalm][ is an open source software. Anyone is free to modify +the source code and contribute to it. All the users are free to +use this software. But the authors are not responsibile for any +damage by THIS SOFTWARE. Please try it at Your Risk! + +Preface: +Because 68000 based Palm devices are barely faster than the +Apple ][, emulation performance may be less than stellar. An +overclocking utility will go a long way to make the emulator +more useable on anything less than a 66Mhz Clie 665C. + +Introduction: +What would be better than being able to take your beloved Apple +][ with you, including most of the software you had for it, all +in your pocket? Here is your chance. The Appalm ][ emulator +brings a 64K Apple //e, no 80 column card, and 2 disk drives, +to your Palm OS based PDA. Disk images can be uploaded into the +internal Palm memory or a memory card (think how many 140K +floppies fit on a 128 MB memory card :-) ) Joystick emulation +is provided using the hard keys available on most Palm PDAs. If +you have one of those Zires without all the keys, then life +sucks for you. The Sony HIRES screen is supported (in color!) - +and looks great too. The Sony Game Controller works very well. +Highly recommended. + +Installation: +You need to install the emulator, appalm.prc, plus the ROM +files apple2e.rom and slot6.rom. Pick a disk image (currently +must be .DSK fomat) and use the DSK2PDB utility to create a +PalmOS DB of the disk image. A '-r' flag can be passed to +DSK2PDB to create a nibblized disk image which can load +slightly faster on the Palm but takes up 220K vs 140K for the +raw data. The standard format database performance has been +improved to the point where I don't know why you would want the +raw format. + +Running: +The basic features of the emulator are available through the +menu. Special keys and joystick options are settable there. You +can return to the Palm Launcher and run other applications. +When you come back to Appalm, it is in the same state as when +you left it. Some of the Palm buttons have been hijacked to +provide useful feature for the emulator. They are: + Calculator - ESC key + Find - CTRL-C + Appointment - Joystick button (1 or 2) + Memo - Joystick button (1 or 2) + Phone/ToDo - Joystick X axis + PgUp/PgDn - Joystick Y axis +A type-ahead buffer is implemented for use with an external +keyboard. You can keep typeing without losing characters. + +Development: +This is a very preliminary version meant more as a +proof-of-concept. More features and performance will be +improved upon. Disk performance is very good now and writing to +the disk image is supported. Sound support would be nice if I +could figure something workable out. Color support for lo-res +(160x160) Palms is in the works. + +Conclusion: +I wanna say thank you to David Schmenk for enhancement of Emulator +and prepare all the works of Appalm][. + +And I can thank Hilary for doing all the initial development +that laid the groundwork for my work. Its much easier if you +have something that already works when developing new emulation +components. + diff --git a/src/6502.asm b/src/6502.asm new file mode 100755 index 0000000..ba75c88 --- /dev/null +++ b/src/6502.asm @@ -0,0 +1,2122 @@ +/********************************************************************************\ +* * +* 6502 emulation * +* * +\********************************************************************************/ + +/* + * STRICT_IND_EMU tries to enforce exact addressing rules as it applies to zero page + * access. Disabling should improve performance and still work in 99.9% of the case. + */ +#define STRICT_IND_EMU 0 +/* + * Define some macros for memory model specific 4addresses. + */ +#define GLOBAL %a5 +#define OPTABLE(o) (opTable6502+(o))@END.w +#define STATE_6502 state6502@END.w +#define STATE_6502_1 (state6502+4)@END.w +#define STATE_6502_2 (state6502+8)@END.w +#define STATUS_6502 status6502@END.w +#define CC_68K_TO_6502 cc_68k_to_6502@END.w +#define CC_6502_TO_68K cc_6502_to_68k@END.w +/* + * Register allocations. + * Note: SP and CC share the same register. + * Use SWAP to get access to the seperate 16 bit halves. + */ +#define DATA %d0 +#define INSTRNS %d1 +#define ACC %d2 +#define X %d3 +#define Y %d4 +#define SP_CC %d5 +#define CC %d5 +#define SP %d5 +#define EA %d6 +#define PAGE %d7 +#define PC %a0 +#define OPBASE %a1 +#define MEMBASE %a2 +#define WRMEM %a3 +#define RDMEM %a4 +#define ADDR %a6 +/* + * Condition code bits. + */ +#define CC_C_68K 0x01 +#define CC_V_68K 0x02 +#define CC_Z_68K 0x04 +#define CC_N_68K 0x08 +#define CC_X_68K 0x10 +#define CC_C_6502 0x01 +#define CC_Z_6502 0x02 +#define CC_I_6502 0x04 +#define CC_D_6502 0x08 +#define CC_B_6502 0x10 +#define CC_1_6502 0x20 +#define CC_V_6502 0x40 +#define CC_N_6502 0x80 +/* + * Effective address calculations. + */ +#define EA_IMM \ + move.b (PC)+, DATA + +#define EA_ZP \ + clr.w EA; \ + mov.b (PC)+, EA + +#define EA_ZP_X \ + move.w X, EA; \ + add.b (PC)+, EA + +#define EA_ZP_Y \ + move.w Y, EA; \ + add.b (PC)+, EA + +#if STRICT_IND_EMU +#define EA_ZP_IND \ + clr.w PAGE; \ + move.b (PC)+, PAGE; \ + move.b (MEMBASE,PAGE.w), DATA; \ + addq.b #1, PAGE; \ + move.b (MEMBASE,PAGE.w), PAGE; \ + lsl.w #2, PAGE; \ + move.w PAGE, EA; \ + lsl.w #6, EA; \ + move.b DATA, EA + +#define EA_IND_X \ + move.w X, PAGE; \ + add.b (PC)+, PAGE; \ + move.b (MEMBASE,PAGE.w), DATA; \ + addq.b #1, PAGE; \ + move.b (MEMBASE,PAGE.w), PAGE; \ + lsl.w #2, PAGE; \ + move.w PAGE, EA; \ + lsl.w #6, EA; \ + move.b DATA, EA + +#define EA_IND_Y \ + clr.w PAGE; \ + move.b (PC)+, PAGE; \ + move.b (MEMBASE,PAGE.w), DATA; \ + addq.b #1, PAGE; \ + move.b (MEMBASE,PAGE.w), EA; \ + lsl.w #8, EA; \ + move.b DATA, EA; \ + add.w Y, EA; \ + move.w EA, PAGE; \ + clr.b PAGE; \ + lsr.w #6, PAGE +#else +#define EA_ZP_IND \ + clr.w PAGE; \ + move.b (PC)+, PAGE; \ + lea 1(MEMBASE,PAGE.w), ADDR; \ + move.b (ADDR), PAGE; \ + lsl.w #2, PAGE; \ + move.w PAGE, EA; \ + lsl.w #6, EA; \ + move.b -(ADDR), EA + +#define EA_IND_X \ + move.w X, PAGE; \ + add.b (PC)+, PAGE; \ + lea 1(MEMBASE,PAGE.w), ADDR; \ + move.b (ADDR), PAGE; \ + lsl.w #2, PAGE; \ + move.w PAGE, EA; \ + lsl.w #6, EA; \ + move.b -(ADDR), EA + +#define EA_IND_Y \ + clr.w PAGE; \ + move.b (PC)+, PAGE; \ + lea 1(MEMBASE,PAGE.w), ADDR; \ + move.b (ADDR), EA; \ + lsl.w #8, EA; \ + move.b -(ADDR), EA; \ + add.w Y, EA; \ + move.w EA, PAGE; \ + clr.b PAGE; \ + lsr.w #6, PAGE +#endif + +#define EA_ABS \ + clr.w PAGE; \ + move.b (PC)+, DATA; \ + move.b (PC)+, PAGE; \ + lsl.w #2, PAGE; \ + move.w PAGE, EA; \ + lsl.w #6, EA; \ + move.b DATA, EA + +#define EA_ABS_X \ + move.b (PC)+, DATA; \ + move.b (PC)+, EA; \ + lsl.w #8, EA; \ + move.b DATA, EA; \ + add.w X, EA; \ + move.w EA, PAGE; \ + clr.b PAGE; \ + lsr.w #6, PAGE + +#define EA_ABS_Y \ + move.b (PC)+, DATA; \ + move.b (PC)+, EA; \ + lsl.w #8, EA; \ + move.b DATA, EA; \ + add.w Y, EA; \ + move.w EA, PAGE; \ + clr.b PAGE; \ + lsr.w #6, PAGE + +/* + * Basic memory read. + */ +#define RD_MEM \ + move.w (RDMEM, PAGE.w), DATA; \ + beq.b 0f; \ + swap DATA; \ + move.w 2(RDMEM, PAGE.w), DATA; \ + move.l DATA, ADDR; \ + jsr (ADDR); \ + bra.b 1f; \ +0:; \ + move.b (MEMBASE,EA.l), DATA; \ +1: + +#define LDA_MEM \ + move.w (RDMEM, PAGE.w), DATA; \ + beq.b 0f; \ + swap DATA; \ + move.w 2(RDMEM, PAGE.w), DATA; \ + move.l DATA, ADDR; \ + jsr (ADDR); \ + move.b DATA, ACC; \ + bra.b 1f; \ +0:; \ + move.b (MEMBASE,EA.l), ACC; \ +1: + +#define LDX_MEM \ + move.w (RDMEM, PAGE.w), DATA; \ + beq.b 0f; \ + swap DATA; \ + move.w 2(RDMEM, PAGE.w), DATA; \ + move.l DATA, ADDR; \ + jsr (ADDR); \ + move.b DATA, X; \ + bra.b 1f; \ +0:; \ + move.b (MEMBASE,EA.l), X; \ +1: + +#define LDY_MEM \ + move.w (RDMEM, PAGE.w), DATA; \ + beq.b 0f; \ + swap DATA; \ + move.w 2(RDMEM, PAGE.w), DATA; \ + move.l DATA, ADDR; \ + jsr (ADDR); \ + move.b DATA, Y; \ + bra.b 1f; \ +0:; \ + move.b (MEMBASE,EA.l), Y; \ +1: + +/* + * Basic memory write. + */ +#define WR_MEM \ + move.w DATA, ADDR; \ + move.w (WRMEM, PAGE.w), DATA; \ + beq.b 0f; \ + swap DATA; \ + move.w 2(WRMEM, PAGE.w), DATA; \ + exg ADDR, DATA; \ + and.l #0xFF, DATA; \ + jsr (ADDR); \ + bra.b 1f; \ +0:; \ + move.w ADDR, DATA; \ + move.b DATA, (MEMBASE, EA.l); \ +1: + +#define STA_MEM \ + move.w (WRMEM, PAGE.w), DATA; \ + beq.b 0f; \ + swap DATA; \ + move.w 2(WRMEM, PAGE.w), DATA; \ + move.l DATA, ADDR; \ + clr.l DATA; \ + move.b ACC, DATA; \ + jsr (ADDR); \ + bra.b 1f; \ +0:; \ + move.b ACC, (MEMBASE, EA.l); \ +1: + +#define STX_MEM \ + move.w (WRMEM, PAGE.w), DATA; \ + beq.b 0f; \ + swap DATA; \ + move.w 2(WRMEM, PAGE.w), DATA; \ + move.l DATA, ADDR; \ + clr.l DATA; \ + move.b X, DATA; \ + jsr (ADDR); \ + bra.b 1f; \ +0:; \ + move.b X, (MEMBASE, EA.l); \ +1: + +#define STY_MEM \ + move.w (WRMEM, PAGE.w), DATA; \ + beq.b 0f; \ + swap DATA; \ + move.w 2(WRMEM, PAGE.w), DATA; \ + move.l DATA, ADDR; \ + clr.l DATA; \ + move.b Y, DATA; \ + jsr (ADDR); \ + bra.b 1f; \ +0:; \ + move.b Y, (MEMBASE, EA.l); \ +1: + +/* + * Memory write when the data is already in the ADDR register. + */ +#define WRA_MEM \ + move.w (WRMEM, PAGE.w), DATA; \ + beq.b 0f; \ + swap DATA; \ + move.w 2(WRMEM, PAGE.w), DATA; \ + exg ADDR, DATA; \ + and.l #0xFF, DATA; \ + jsr (ADDR); \ + bra.b 1f; \ +0:; \ + move.w ADDR, DATA; \ + move.b DATA, (MEMBASE, EA.l); \ +1: +/* + * Decrement instruction count and fetch next instruction. + */ +#define NEXT_OP \ + dbf.w INSTRNS, opfetch; \ + bra.w exit6502 +/* + * Update CC flags. + */ +#define UPDATE_Z_STATUS \ + move.w %sr, DATA; \ + and.b #0x04, DATA; \ + and.b #0x1D, CC; \ + or.b DATA, CC + +#define UPDATE_NZ_STATUS \ + move.w %sr, DATA; \ + and.b #0x0C, DATA; \ + and.b #0x13, CC; \ + or.b DATA, CC + +#define UPDATE_NZC_STATUS \ + move.w %sr, DATA; \ + and.b #0x1D, DATA; \ + and.b #0x02, CC; \ + or.b DATA, CC + +/* + * Opcodes. + */ +#define OP_BIT \ + and.b #0x11, CC; \ + move.w CC, ADDR; \ + btst #7, DATA; \ + sne CC; \ + and.b #0x08, CC; \ + add.w CC, ADDR; \ + btst #6, DATA; \ + sne CC; \ + and.b #0x02, CC; \ + add.w CC, ADDR; \ + and.b ACC, DATA; \ + move.w %sr, CC; \ + and.b #0x04, CC; \ + add.w ADDR, CC + +#define OP_TRB \ + and.b #0x11, CC; \ + move.w CC, ADDR; \ + btst #7, DATA; \ + sne CC; \ + and.b #0x08, CC; \ + add.w CC, ADDR; \ + btst #6, DATA; \ + sne CC; \ + and.b #0x02, CC; \ + add.w CC, ADDR; \ + not.b ACC; \ + and.b ACC, DATA; \ + move.w %sr, CC; \ + and.b #0x04, CC; \ + add.w ADDR, CC; \ + not.b ACC + +#define OP_TSB \ + and.b #0x11, CC; \ + btst #7, DATA; \ + sne CC; \ + and.b #0x08, CC; \ + add.w CC, ADDR; \ + btst #6, DATA; \ + sne CC; \ + and.b #0x02, CC; \ + add.w CC, ADDR; \ + or.b ACC, DATA; \ + move.w %sr, CC; \ + and.b #0x04, CC; \ + add.w ADDR, CC + +#define OP_ADC_BIN \ + or.b #0x04, CC; \ + move.w CC, %ccr; \ + addx.b DATA, ACC; \ + move.w %sr, CC + +#define OP_ADC_BCD \ + or.b #0x04, CC; \ + move.w CC, %ccr; \ + abcd DATA, ACC; \ + move.w %sr, CC + +#define OP_SBC_BIN \ + eor.b #0x11, CC; \ + or.b #0x04, CC; \ + move.w CC, %ccr; \ + subx.b DATA, ACC; \ + move.w %sr, CC; \ + eor.b #0x11, CC + +#define OP_SBC_BCD \ + eor.b #0x11, CC; \ + or.b #0x04, CC; \ + move.w CC, %ccr; \ + sbcd DATA, ACC; \ + move.w %sr, CC; \ + eor.b #0x11, CC + +.data +.even +/* + * Condition Code/Status Register translation tables. + */ +cc_6502_to_68k: + .byte 0x00; .byte 0x02; .byte 0x08; .byte 0x0A; + .byte 0x11; .byte 0x13; .byte 0x19; .byte 0x1B; + .byte 0x04; .byte 0x06; .byte 0x0C; .byte 0x0E; + .byte 0x15; .byte 0x17; .byte 0x1D; .byte 0x1F; +cc_68k_to_6502: + .byte 0x00; .byte 0x01; .byte 0x40; .byte 0x41; + .byte 0x02; .byte 0x03; .byte 0x42; .byte 0x43; + .byte 0x80; .byte 0x81; .byte 0xC0; .byte 0xC1; + .byte 0x82; .byte 0x83; .byte 0xC2; .byte 0xC3; +.text +.even +/* + * uCode. + */ +UNIMPLEMENTED: + move.l PC, DATA + subq.l #1, DATA + move.l DATA, PC + sub.l MEMBASE, DATA + swap DATA + move.b (PC), DATA + movem.l #0x1FFC, STATE_6502_2(GLOBAL) /* Save 6502 state */ + movem.l (%sp)+, #0x7FFE /* Restore all registers */ + rts +NOP: + NEXT_OP +CLD: + and.b #~CC_D_6502, STATUS_6502(GLOBAL) + bsr.w set_bcd_ops + NEXT_OP +SED: + or.b #CC_D_6502, STATUS_6502(GLOBAL) + bsr.w set_bcd_ops + NEXT_OP +CLC: + and.b #0xEE, CC + NEXT_OP +SEC: + or.b #0x11, CC + NEXT_OP +CLV: + and.b #0xFD, CC + NEXT_OP +SEI: + or.b #CC_I_6502, STATUS_6502(GLOBAL) + NEXT_OP +CLI: + and.b #~CC_I_6502, STATUS_6502(GLOBAL) + NEXT_OP +PHP: + move.b CC, DATA + and.w #0x0F, DATA + lea CC_68K_TO_6502(GLOBAL), ADDR + move.b (ADDR,DATA.w), DATA + or.b STATUS_6502(GLOBAL), DATA + swap SP_CC /* SP is high 16 bits of SP_CC */ + move.b DATA, (MEMBASE,SP.w) + subq.b #1, SP + swap SP_CC + NEXT_OP +PHA: + swap SP_CC /* SP is high 16 bits of SP_CC */ + move.b ACC, (MEMBASE,SP.w) + subq.b #1, SP + swap SP_CC + NEXT_OP +PHX: + swap SP_CC /* SP is high 16 bits of SP_CC */ + move.b X, (MEMBASE,SP.w) + subq.b #1, SP + swap SP_CC + NEXT_OP +PLP: + swap SP_CC /* SP is high 16 bits of SP_CC */ + addq.b #1, SP + move.b (MEMBASE,SP.w), DATA + swap SP_CC + clr.w CC + move.b DATA, CC + and.b #0x3C, DATA /* Mask out mapped state */ + and.b #0xC3, CC + move.b DATA, STATUS_6502(GLOBAL) + rol.b #2, CC + lea CC_6502_TO_68K(GLOBAL), ADDR + move.b (ADDR,CC.w), CC + bsr.w set_bcd_ops + NEXT_OP +PLA: + swap SP_CC /* SP is high 16 bits of SP_CC */ + addq.b #1, SP + move.w SP, ADDR + swap SP_CC + move.b (MEMBASE,ADDR.w), ACC + UPDATE_NZ_STATUS + NEXT_OP +PLX: + swap SP_CC /* SP is high 16 bits of SP_CC */ + addq.b #1, SP + move.w SP, ADDR + swap SP_CC + move.b (MEMBASE,ADDR.w), X + UPDATE_NZ_STATUS + NEXT_OP +BRK: + sub.l MEMBASE, PC /* Push PC + 2 */ + move.w PC, DATA + addq #1, DATA + ror.w #8, DATA + swap SP_CC /* SP is high 16 bits of SP_CC */ + move.b DATA, (MEMBASE,SP.w) + lsr.w #8, DATA + subq.b #1, SP + move.b DATA, (MEMBASE,SP.w) + subq.b #1, SP + swap SP_CC + or.b #CC_B_6502, STATUS_6502(GLOBAL) /* Set BRK flag */ + move.b CC, DATA /* Push P */ + and.w #0x0F, DATA + lea CC_68K_TO_6502(GLOBAL), ADDR + move.b (ADDR,DATA.w), DATA + or.b STATUS_6502(GLOBAL), DATA + swap SP_CC /* SP is high 16 bits of SP_CC */ + move.b DATA, (MEMBASE,SP.w) + subq.b #1, SP + swap SP_CC + or.b #CC_I_6502, STATUS_6502(GLOBAL) /* Set INT flag */ + move.l #0xFFFE, DATA /* Load PC from 0xFFFE */ + move.w (MEMBASE,DATA.l), DATA + ror.w #8, DATA + move.l DATA, PC + add.l MEMBASE, PC + NEXT_OP +JMP_ABS: + move.b 1(PC), DATA + lsl.w #8, DATA + move.b (PC), DATA + lea (MEMBASE,DATA.l), PC + NEXT_OP +JMP_IND: /* 65C02 version */ + move.b 1(PC), DATA + lsl.w #8, DATA + move.b (PC), DATA + lea 1(MEMBASE,DATA.l), ADDR + move.b (ADDR), DATA + lsl.w #8, DATA + move.b -(ADDR), DATA + lea (MEMBASE,DATA.l), PC + NEXT_OP +JSR: + swap SP_CC /* SP is high 16 bits of SP_CC */ + move.b 1(PC), DATA + lsl.w #8, DATA + move.b (PC)+, DATA + move.l DATA, ADDR + sub.l MEMBASE, PC + move.w PC, DATA + move.l ADDR, PC + add.l MEMBASE, PC + ror.w #8, DATA + move.b DATA, (MEMBASE,SP.w) + lsr.w #8, DATA + subq.b #1, SP + move.b DATA, (MEMBASE,SP.w) + subq.b #1, SP + swap SP_CC + NEXT_OP +RTS: + swap SP_CC /* SP is high 16 bits of SP_CC */ + addq.b #1, SP + move.b (MEMBASE,SP.w), DATA + addq.b #1, SP + lsl.w #8, DATA + move.b (MEMBASE,SP.w), DATA + rol.w #8, DATA + lea 1(MEMBASE,DATA.l), PC + swap SP_CC + NEXT_OP +RTI: + swap SP_CC /* SP is high 16 bits of SP_CC */ + addq.b #1, SP + move.b (MEMBASE,SP.w), DATA + swap SP_CC + clr.w CC + move.b DATA, CC + and.b #0x3C, DATA /* Mask out mapped state */ + move.b DATA, STATUS_6502(GLOBAL) + and.b #0xC3, CC + rol.b #2, CC + lea CC_6502_TO_68K(GLOBAL), ADDR + move.b (ADDR,CC.w), CC + bsr.w set_bcd_ops + swap SP_CC + addq.b #1, SP + move.b (MEMBASE,SP.w), DATA + addq.b #1, SP + lsl.w #8, DATA + move.b (MEMBASE,SP.w), DATA + rol.w #8, DATA + lea (MEMBASE,DATA.l), PC + swap SP_CC + NEXT_OP +/* + * Special version of PC adjustment routines that check for specific ranges. + * Very Apple ][ specific :-( + */ +BRK_CHK: + movem.l #0x1FFF, STATE_6502(GLOBAL) + bsr.w updateLanguageCardMapping + movem.l STATE_6502(GLOBAL), #0x1FFF + sub.l MEMBASE, PC /* Push PC + 2 */ + move.w PC, DATA + addq #1, DATA + ror.w #8, DATA + swap SP_CC /* SP is high 16 bits of SP_CC */ + move.b DATA, (MEMBASE,SP.w) + lsr.w #8, DATA + subq.b #1, SP + move.b DATA, (MEMBASE,SP.w) + subq.b #1, SP + swap SP_CC + or.b #CC_B_6502, STATUS_6502(GLOBAL) /* Set BRK flag */ + move.b CC, DATA /* Push P */ + and.w #0x0F, DATA + lea CC_68K_TO_6502(GLOBAL), ADDR + move.b (ADDR,DATA.w), DATA + or.b STATUS_6502(GLOBAL), DATA + swap SP_CC /* SP is high 16 bits of SP_CC */ + move.b DATA, (MEMBASE,SP.w) + subq.b #1, SP + swap SP_CC + or.b #CC_I_6502, STATUS_6502(GLOBAL) /* Set INT flag */ + move.l #0xFFFE, DATA /* Load PC from 0xFFFE */ + move.w (MEMBASE,DATA.l), DATA + ror.w #8, DATA + move.l DATA, PC + add.l MEMBASE, PC + NEXT_OP +JMP_ABS_CHK: + move.b 1(PC), DATA + lsl.w #8, DATA + move.b (PC), DATA + cmp.w #0xD000, DATA + bcs.b 0f + movem.l #0x1FFF, STATE_6502(GLOBAL) + bsr.w updateLanguageCardMapping + movem.l STATE_6502(GLOBAL), #0x1FFF +0: + lea (MEMBASE,DATA.l), PC + NEXT_OP +JMP_IND_CHK: /* 65C02 version */ + move.b 1(PC), DATA + lsl.w #8, DATA + move.b (PC), DATA + cmp.w #0xD000, DATA + bcs.b 0f + movem.l #0x1FFF, STATE_6502(GLOBAL) + bsr.w updateLanguageCardMapping + movem.l STATE_6502(GLOBAL), #0x1FFF +0: + lea 1(MEMBASE,DATA.l), ADDR + move.b (ADDR), DATA + lsl.w #8, DATA + move.b -(ADDR), DATA + cmp.w #0xD000, DATA + bcs.b 1f + movem.l #0x1FFF, STATE_6502(GLOBAL) + bsr.w updateLanguageCardMapping + movem.l STATE_6502(GLOBAL), #0x1FFF +1: + lea (MEMBASE,DATA.l), PC + NEXT_OP +JSR_CHK: + swap SP_CC /* SP is high 16 bits of SP_CC */ + move.b 1(PC), DATA + lsl.w #8, DATA + move.b (PC)+, DATA + cmp.w #0xD000, DATA + bcs.b 0f + movem.l #0x1FFF, STATE_6502(GLOBAL) + bsr.w updateLanguageCardMapping + movem.l STATE_6502(GLOBAL), #0x1FFF +0: + move.l DATA, ADDR + sub.l MEMBASE, PC + move.w PC, DATA + move.l ADDR, PC + add.l MEMBASE, PC + ror.w #8, DATA + move.b DATA, (MEMBASE,SP.w) + lsr.w #8, DATA + subq.b #1, SP + move.b DATA, (MEMBASE,SP.w) + subq.b #1, SP + swap SP_CC + NEXT_OP +RTS_CHK: + swap SP_CC /* SP is high 16 bits of SP_CC */ + addq.b #1, SP + move.b (MEMBASE,SP.w), DATA + addq.b #1, SP + lsl.w #8, DATA + move.b (MEMBASE,SP.w), DATA + rol.w #8, DATA + cmp.w #0xEFFF, DATA + bcs.b 0f + movem.l #0x1FFF, STATE_6502(GLOBAL) + bsr.w updateLanguageCardMapping + movem.l STATE_6502(GLOBAL), #0x1FFF +0: + lea 1(MEMBASE,DATA.l), PC + swap SP_CC + NEXT_OP +RTI_CHK: + swap SP_CC /* SP is high 16 bits of SP_CC */ + addq.b #1, SP + move.b (MEMBASE,SP.w), DATA + swap SP_CC + clr.w CC + move.b DATA, CC + and.b #0x3C, DATA /* Mask out mapped state */ + move.b DATA, STATUS_6502(GLOBAL) + and.b #0xC3, CC + rol.b #2, CC + lea CC_6502_TO_68K(GLOBAL), ADDR + move.b (ADDR,CC.w), CC + bsr.w set_bcd_ops + swap SP_CC + addq.b #1, SP + move.b (MEMBASE,SP.w), DATA + addq.b #1, SP + lsl.w #8, DATA + move.b (MEMBASE,SP.w), DATA + rol.w #8, DATA + cmp.w #0xD000, DATA + bcs.b 0f + movem.l #0x1FFF, STATE_6502(GLOBAL) + bsr.w updateLanguageCardMapping + movem.l STATE_6502(GLOBAL), #0x1FFF +0: + lea (MEMBASE,DATA.l), PC + swap SP_CC + NEXT_OP +BRA: + move.b (PC)+, DATA + ext.w DATA + add.w DATA, PC + NEXT_OP +BCS: + move.b (PC)+, DATA + btst #0, CC + beq.b .+6 + ext.w DATA + add.w DATA, PC + NEXT_OP +BCC: + move.b (PC)+, DATA + btst #0, CC + bne.b .+6 + ext.w DATA + add.w DATA, PC + NEXT_OP +BEQ: + move.b (PC)+, DATA + btst #2, CC + beq.b .+6 + ext.w DATA + add.w DATA, PC + NEXT_OP +BNE: + move.b (PC)+, DATA + btst #2, CC + bne.b .+6 + ext.w DATA + add.w DATA, PC + NEXT_OP +BMI: + move.b (PC)+, DATA + btst #3, CC + beq.b .+6 + ext.w DATA + add.w DATA, PC + NEXT_OP +BPL: + move.b (PC)+, DATA + btst #3, CC + bne.b .+6 + ext.w DATA + add.w DATA, PC + NEXT_OP +BVS: + move.b (PC)+, DATA + btst #1, CC + beq.b .+6 + ext.w DATA + add.w DATA, PC + NEXT_OP +BVC: + move.b (PC)+, DATA + btst #1, CC + bne.b .+6 + ext.w DATA + add.w DATA, PC + NEXT_OP +LDA_IMM: + move.b (PC)+, ACC + UPDATE_NZ_STATUS + NEXT_OP +LDA_ZP: + EA_ZP + move.b (MEMBASE,EA.w), ACC + UPDATE_NZ_STATUS + NEXT_OP +LDA_ZP_X: + EA_ZP_X + move.b (MEMBASE,EA.w), ACC + UPDATE_NZ_STATUS + NEXT_OP +LDA_ZP_IND: + EA_ZP_IND + LDA_MEM + UPDATE_NZ_STATUS + NEXT_OP +LDA_IND_Y: + EA_IND_Y + LDA_MEM + UPDATE_NZ_STATUS + NEXT_OP +LDA_IND_X: + EA_IND_X + LDA_MEM + UPDATE_NZ_STATUS + NEXT_OP +LDA_ABS: + EA_ABS + LDA_MEM + UPDATE_NZ_STATUS + NEXT_OP +LDA_ABS_Y: + EA_ABS_Y + LDA_MEM + UPDATE_NZ_STATUS + NEXT_OP +LDA_ABS_X: + EA_ABS_X + LDA_MEM + UPDATE_NZ_STATUS + NEXT_OP +LDY_IMM: + move.b (PC)+, Y + UPDATE_NZ_STATUS + NEXT_OP +LDY_ZP: + EA_ZP + move.b (MEMBASE,EA.w), Y + UPDATE_NZ_STATUS + NEXT_OP +LDY_ZP_X: + EA_ZP_X + move.b (MEMBASE,EA.w), Y + UPDATE_NZ_STATUS + NEXT_OP +LDY_ABS: + EA_ABS + LDY_MEM + UPDATE_NZ_STATUS + NEXT_OP +LDY_ABS_X: + EA_ABS_X + LDY_MEM + UPDATE_NZ_STATUS + NEXT_OP +LDX_IMM: + move.b (PC)+, X + UPDATE_NZ_STATUS + NEXT_OP +LDX_ZP: + EA_ZP + move.b (MEMBASE,EA.w), X + UPDATE_NZ_STATUS + NEXT_OP +LDX_ZP_Y: + EA_ZP_Y + move.b (MEMBASE,EA.w), X + UPDATE_NZ_STATUS + NEXT_OP +LDX_ABS: + EA_ABS + LDX_MEM + UPDATE_NZ_STATUS + NEXT_OP +LDX_ABS_Y: + EA_ABS_Y + LDX_MEM + UPDATE_NZ_STATUS + NEXT_OP +STA_ZP: + EA_ZP + move.b ACC, (MEMBASE,EA.w) + NEXT_OP +STA_ZP_X: + EA_ZP_X + move.b ACC, (MEMBASE,EA.w) + NEXT_OP +STA_IND_Y: + EA_IND_Y + STA_MEM + NEXT_OP +STA_IND_X: + EA_IND_X + STA_MEM + NEXT_OP +STA_ABS: + EA_ABS + STA_MEM + NEXT_OP +STA_ABS_Y: + EA_ABS_Y + STA_MEM + NEXT_OP +STA_ABS_X: + EA_ABS_X + STA_MEM + NEXT_OP +STY_ZP: + EA_ZP + move.b Y, (MEMBASE,EA.w) + NEXT_OP +STY_ZP_X: + EA_ZP_X + move.b Y, (MEMBASE,EA.w) + NEXT_OP +STY_ABS: + EA_ABS + STY_MEM + NEXT_OP +STX_ZP_Y: + EA_ZP_Y + move.b X, (MEMBASE,EA.w) + NEXT_OP +STX_ZP: + EA_ZP + move.b X, (MEMBASE,EA.w) + NEXT_OP +STX_ABS: + EA_ABS + STX_MEM + NEXT_OP +STZ_ZP: + EA_ZP + move.b #0, (MEMBASE,EA.w) + NEXT_OP +STZ_ABS: + EA_ABS + clr.w DATA + WR_MEM + NEXT_OP +STZ_ABS_X: + EA_ABS_X + clr.w DATA + WR_MEM + NEXT_OP +TAY: + move.b ACC, Y + UPDATE_NZ_STATUS + NEXT_OP +TYA: + move.b Y, ACC + UPDATE_NZ_STATUS + NEXT_OP +TAX: + move.b ACC, X + UPDATE_NZ_STATUS + NEXT_OP +TXA: + move.b X, ACC + UPDATE_NZ_STATUS + NEXT_OP +TXS: + swap SP_CC + move.b X, SP + swap SP_CC + NEXT_OP +TSX: + swap SP_CC + move.b SP, DATA + swap SP_CC + move.b DATA, X + UPDATE_NZ_STATUS + NEXT_OP +BIT_IMM: + EA_IMM + OP_BIT + NEXT_OP +BIT_ZP: + EA_ZP + move.b (MEMBASE,EA.w), DATA + OP_BIT + NEXT_OP +BIT_ABS: + EA_ABS + RD_MEM + OP_BIT + NEXT_OP +TRB_ABS: + EA_ABS + RD_MEM + OP_TRB + WR_MEM + NEXT_OP +TSB_ZP: + EA_ZP + move.b (MEMBASE,EA.w), DATA + OP_TSB + move.b DATA, (MEMBASE,EA.w) + NEXT_OP +TSB_ABS: + EA_ABS + RD_MEM + OP_TSB + WR_MEM + NEXT_OP +AND_IMM: + and.b (PC)+, ACC + UPDATE_NZ_STATUS + NEXT_OP +AND_ZP: + EA_ZP + and.b (MEMBASE,EA.w), ACC + UPDATE_NZ_STATUS + NEXT_OP +AND_ZP_X: + EA_ZP_X + and.b (MEMBASE,EA.w), ACC + UPDATE_NZ_STATUS + NEXT_OP +AND_ABS: + EA_ABS + RD_MEM + and.b DATA, ACC + UPDATE_NZ_STATUS + NEXT_OP +AND_ABS_Y: + EA_ABS_Y + RD_MEM + and.b DATA, ACC + UPDATE_NZ_STATUS + NEXT_OP +AND_ABS_X: + EA_ABS_X + RD_MEM + and.b DATA, ACC + UPDATE_NZ_STATUS + NEXT_OP +AND_IND_Y: + EA_IND_Y + RD_MEM + and.b DATA, ACC + UPDATE_NZ_STATUS + NEXT_OP +AND_IND_X: + EA_IND_X + RD_MEM + and.b DATA, ACC + UPDATE_NZ_STATUS + NEXT_OP +ORA_IMM: + or.b (PC)+, ACC + UPDATE_NZ_STATUS + NEXT_OP +ORA_ZP: + EA_ZP + or.b (MEMBASE,EA.w), ACC + UPDATE_NZ_STATUS + NEXT_OP +ORA_ZP_X: + EA_ZP_X + or.b (MEMBASE,EA.w), ACC + UPDATE_NZ_STATUS + NEXT_OP +ORA_ABS: + EA_ABS + RD_MEM + or.b DATA, ACC + UPDATE_NZ_STATUS + NEXT_OP +ORA_ABS_Y: + EA_ABS_Y + RD_MEM + or.b DATA, ACC + UPDATE_NZ_STATUS + NEXT_OP +ORA_ABS_X: + EA_ABS_X + RD_MEM + or.b DATA, ACC + UPDATE_NZ_STATUS + NEXT_OP +ORA_IND_Y: + EA_IND_Y + RD_MEM + or.b DATA, ACC + UPDATE_NZ_STATUS + NEXT_OP +ORA_IND_X: + EA_IND_X + RD_MEM + or.b DATA, ACC + UPDATE_NZ_STATUS + NEXT_OP +EOR_IMM: + EA_IMM + eor.b DATA, ACC + UPDATE_NZ_STATUS + NEXT_OP +EOR_ZP: + EA_ZP + move.b (MEMBASE,EA.w), DATA + eor.b DATA, ACC + UPDATE_NZ_STATUS + NEXT_OP +EOR_ZP_X: + EA_ZP_X + move.b (MEMBASE,EA.w), DATA + eor.b DATA, ACC + UPDATE_NZ_STATUS + NEXT_OP +EOR_ABS: + EA_ABS + RD_MEM + eor.b DATA, ACC + UPDATE_NZ_STATUS + NEXT_OP +EOR_ABS_Y: + EA_ABS_Y + RD_MEM + eor.b DATA, ACC + UPDATE_NZ_STATUS + NEXT_OP +EOR_ABS_X: + EA_ABS_X + RD_MEM + eor.b DATA, ACC + UPDATE_NZ_STATUS + NEXT_OP +EOR_IND_Y: + EA_IND_Y + RD_MEM + eor.b DATA, ACC + UPDATE_NZ_STATUS + NEXT_OP +EOR_IND_X: + EA_IND_X + RD_MEM + eor.b DATA, ACC + UPDATE_NZ_STATUS + NEXT_OP +INC_ZP: + EA_ZP + addq.b #1, (MEMBASE,EA.w) + UPDATE_NZ_STATUS + NEXT_OP +INC_ZP_X: + EA_ZP_X + addq.b #1, (MEMBASE,EA.w) + UPDATE_NZ_STATUS + NEXT_OP +INC_ABS: + EA_ABS + RD_MEM + addq.b #1, DATA + move.w DATA, ADDR + UPDATE_NZ_STATUS + WRA_MEM + NEXT_OP +INC_ABS_X: + EA_ABS_X + RD_MEM + addq.b #1, DATA + move.w DATA, ADDR + UPDATE_NZ_STATUS + WRA_MEM + NEXT_OP +INA: + addq.b #1, ACC + UPDATE_NZ_STATUS + NEXT_OP +INY: + addq.b #1, Y + UPDATE_NZ_STATUS + NEXT_OP +INX: + addq.b #1, X + UPDATE_NZ_STATUS + NEXT_OP +DEC_ZP: + EA_ZP + subq.b #1, (MEMBASE,EA.w) + UPDATE_NZ_STATUS + NEXT_OP +DEC_ZP_X: + EA_ZP_X + subq.b #1, (MEMBASE,EA.w) + UPDATE_NZ_STATUS + NEXT_OP +DEC_ABS: + EA_ABS + RD_MEM + subq.b #1, DATA + move.w DATA, ADDR + UPDATE_NZ_STATUS + WRA_MEM + NEXT_OP +DEC_ABS_X: + EA_ABS_X + RD_MEM + subq.b #1, DATA + move.w DATA, ADDR + UPDATE_NZ_STATUS + WRA_MEM + NEXT_OP +DEA: + subq.b #1, ACC + UPDATE_NZ_STATUS + NEXT_OP +DEY: + subq.b #1, Y + UPDATE_NZ_STATUS + NEXT_OP +DEX: + subq.b #1, X + UPDATE_NZ_STATUS + NEXT_OP +ADC_BIN_IMM: + EA_IMM + OP_ADC_BIN + NEXT_OP +ADC_BIN_ZP: + EA_ZP + move.b (MEMBASE,EA.w), DATA + OP_ADC_BIN + NEXT_OP +ADC_BIN_ZP_X: + EA_ZP_X + move.b (MEMBASE,EA.w), DATA + OP_ADC_BIN + NEXT_OP +ADC_BIN_ABS: + EA_ABS + RD_MEM + OP_ADC_BIN + NEXT_OP +ADC_BIN_ABS_X: + EA_ABS_X + RD_MEM + OP_ADC_BIN + NEXT_OP +ADC_BIN_ABS_Y: + EA_ABS_Y + RD_MEM + OP_ADC_BIN + NEXT_OP +ADC_BIN_IND_X: + EA_IND_X + RD_MEM + OP_ADC_BIN + NEXT_OP +ADC_BIN_IND_Y: + EA_IND_Y + RD_MEM + OP_ADC_BIN + NEXT_OP +ADC_BCD_IMM: + EA_IMM + OP_ADC_BCD + NEXT_OP +ADC_BCD_ZP: + EA_ZP + move.b (MEMBASE,EA.w), DATA + OP_ADC_BCD + NEXT_OP +ADC_BCD_ZP_X: + EA_ZP_X + move.b (MEMBASE,EA.w), DATA + OP_ADC_BCD + NEXT_OP +ADC_BCD_ABS: + EA_ABS + RD_MEM + OP_ADC_BCD + NEXT_OP +ADC_BCD_ABS_X: + EA_ABS_X + RD_MEM + OP_ADC_BCD + NEXT_OP +ADC_BCD_ABS_Y: + EA_ABS_Y + RD_MEM + OP_ADC_BCD + NEXT_OP +ADC_BCD_IND_X: + EA_IND_X + RD_MEM + OP_ADC_BCD + NEXT_OP +ADC_BCD_IND_Y: + EA_IND_Y + RD_MEM + OP_ADC_BCD + NEXT_OP +SBC_BIN_IMM: + EA_IMM + OP_SBC_BIN + NEXT_OP +SBC_BIN_ZP: + EA_ZP + move.b (MEMBASE,EA.w), DATA + OP_SBC_BIN + NEXT_OP +SBC_BIN_ZP_X: + EA_ZP_X + move.b (MEMBASE,EA.w), DATA + OP_SBC_BIN + NEXT_OP +SBC_BIN_ABS: + EA_ABS + RD_MEM + OP_SBC_BIN + NEXT_OP +SBC_BIN_ABS_X: + EA_ABS_X + RD_MEM + OP_SBC_BIN + NEXT_OP +SBC_BIN_ABS_Y: + EA_ABS_Y + RD_MEM + OP_SBC_BIN + NEXT_OP +SBC_BIN_IND_X: + EA_IND_X + RD_MEM + OP_SBC_BIN + NEXT_OP +SBC_BIN_IND_Y: + EA_IND_Y + RD_MEM + OP_SBC_BIN + NEXT_OP +SBC_BCD_IMM: + EA_IMM + OP_SBC_BCD + NEXT_OP +SBC_BCD_ZP: + EA_ZP + move.b (MEMBASE,EA.w), DATA + OP_SBC_BCD + NEXT_OP +SBC_BCD_ZP_X: + EA_ZP_X + move.b (MEMBASE,EA.w), DATA + OP_SBC_BCD + NEXT_OP +SBC_BCD_ABS: + EA_ABS + RD_MEM + OP_SBC_BCD + NEXT_OP +SBC_BCD_ABS_X: + EA_ABS_X + RD_MEM + OP_SBC_BCD + NEXT_OP +SBC_BCD_ABS_Y: + EA_ABS_Y + RD_MEM + OP_SBC_BCD + NEXT_OP +SBC_BCD_IND_X: + EA_IND_X + RD_MEM + OP_SBC_BCD + NEXT_OP +SBC_BCD_IND_Y: + EA_IND_Y + RD_MEM + OP_SBC_BCD + NEXT_OP +CMP_IMM: + move.w ACC, DATA + sub.b (PC)+, DATA + UPDATE_NZC_STATUS + eor.b #0x11, CC + NEXT_OP +CMP_ZP: + EA_ZP + move.w ACC, DATA + sub.b (MEMBASE,EA.w), DATA + UPDATE_NZC_STATUS + eor.b #0x11, CC + NEXT_OP +CMP_ZP_IND: + EA_ZP_IND + RD_MEM + move.w ACC, ADDR + sub.b DATA, ACC + UPDATE_NZC_STATUS + eor.b #0x11, CC + move.w ADDR, ACC + NEXT_OP +CMP_ZP_X: + EA_ZP_X + move.w ACC, DATA + sub.b (MEMBASE,EA.w), DATA + UPDATE_NZC_STATUS + eor.b #0x11, CC + NEXT_OP +CMP_IND_Y: + EA_IND_Y + RD_MEM + move.w ACC, ADDR + sub.b DATA, ACC + UPDATE_NZC_STATUS + eor.b #0x11, CC + move.w ADDR, ACC + NEXT_OP +CMP_IND_X: + EA_IND_X + RD_MEM + move.w ACC, ADDR + sub.b DATA, ACC + UPDATE_NZC_STATUS + eor.b #0x11, CC + move.w ADDR, ACC + NEXT_OP +CMP_ABS: + EA_ABS + RD_MEM + move.w ACC, ADDR + sub.b DATA, ACC + UPDATE_NZC_STATUS + eor.b #0x11, CC + move.w ADDR, ACC + NEXT_OP +CMP_ABS_Y: + EA_ABS_Y + RD_MEM + move.w ACC, ADDR + sub.b DATA, ACC + UPDATE_NZC_STATUS + eor.b #0x11, CC + move.w ADDR, ACC + NEXT_OP +CMP_ABS_X: + EA_ABS_X + RD_MEM + move.w ACC, ADDR + sub.b DATA, ACC + UPDATE_NZC_STATUS + eor.b #0x11, CC + move.w ADDR, ACC + NEXT_OP +CPY_IMM: + move.w Y, DATA + sub.b (PC)+, DATA + UPDATE_NZC_STATUS + eor.b #0x11, CC + NEXT_OP +CPY_ZP: + EA_ZP + move.w Y, DATA + sub.b (MEMBASE,EA.w), DATA + UPDATE_NZC_STATUS + eor.b #0x11, CC + NEXT_OP +CPY_ABS: + EA_ABS + RD_MEM + move.w Y, ADDR + sub.b DATA, Y + UPDATE_NZC_STATUS + eor.b #0x11, CC + move.w ADDR, Y + NEXT_OP +CPX_IMM: + move.w X, DATA + sub.b (PC)+, DATA + UPDATE_NZC_STATUS + eor.b #0x11, CC + NEXT_OP +CPX_ZP: + EA_ZP + move.w X, DATA + sub.b (MEMBASE,EA.w), DATA + UPDATE_NZC_STATUS + eor.b #0x11, CC + NEXT_OP +CPX_ABS: + EA_ABS + RD_MEM + move.w X, ADDR + sub.b DATA, X + UPDATE_NZC_STATUS + eor.b #0x11, CC + move.w ADDR, X + NEXT_OP +ASL_ACC: + asl.b #1, ACC + UPDATE_NZC_STATUS + NEXT_OP +ASL_ZP: + EA_ZP + move.b (MEMBASE,EA.w), DATA + asl.b #1, DATA + move.w DATA, ADDR + UPDATE_NZC_STATUS + move.w ADDR, DATA + move.b DATA, (MEMBASE,EA.w) + NEXT_OP +ASL_ZP_X: + EA_ZP_X + move.b (MEMBASE,EA.w), DATA + asl.b #1, DATA + move.w DATA, ADDR + UPDATE_NZC_STATUS + move.w ADDR, DATA + move.b DATA, (MEMBASE,EA.w) + NEXT_OP +ASL_ABS: + EA_ABS + RD_MEM + asl.b #1, DATA + move.w DATA, ADDR + UPDATE_NZC_STATUS + WRA_MEM + NEXT_OP +ASL_ABS_X: + EA_ABS_X + RD_MEM + asl.b #1, DATA + move.w DATA, ADDR + UPDATE_NZC_STATUS + WRA_MEM + NEXT_OP +LSR_ACC: + lsr.b #1, ACC + UPDATE_NZC_STATUS + NEXT_OP +LSR_ZP: + EA_ZP + move.b (MEMBASE,EA.w), DATA + lsr.b #1, DATA + move.w DATA, ADDR + UPDATE_NZC_STATUS + move.w ADDR, DATA + move.b DATA, (MEMBASE,EA.w) + NEXT_OP +LSR_ZP_X: + EA_ZP_X + move.b (MEMBASE,EA.w), DATA + lsr.b #1, DATA + move.w DATA, ADDR + UPDATE_NZC_STATUS + move.w ADDR, DATA + move.b DATA, (MEMBASE,EA.w) + NEXT_OP +LSR_ABS: + EA_ABS + RD_MEM + lsr.b #1, DATA + move.w DATA, ADDR + UPDATE_NZC_STATUS + WRA_MEM + NEXT_OP +LSR_ABS_X: + EA_ABS_X + RD_MEM + lsr.b #1, DATA + move.w DATA, ADDR + UPDATE_NZC_STATUS + WRA_MEM + NEXT_OP +ROL_ACC: + move.w CC, %ccr + roxl.b #1, ACC + UPDATE_NZC_STATUS + NEXT_OP +ROL_ZP: + EA_ZP + move.b (MEMBASE,EA.w), DATA + move.w CC, %ccr + roxl.b #1, DATA + move.w DATA, ADDR + UPDATE_NZC_STATUS + move.w ADDR, DATA + move.b DATA, (MEMBASE,EA.w) + NEXT_OP +ROL_ZP_X: + EA_ZP_X + move.b (MEMBASE,EA.w), DATA + move.w CC, %ccr + roxl.b #1, DATA + move.w DATA, ADDR + UPDATE_NZC_STATUS + move.w ADDR, DATA + move.b DATA, (MEMBASE,EA.w) + NEXT_OP +ROL_ABS: + EA_ABS + RD_MEM + move.w CC, %ccr + roxl.b #1, DATA + move.w DATA, ADDR + UPDATE_NZC_STATUS + WRA_MEM + NEXT_OP +ROL_ABS_X: + EA_ABS_X + RD_MEM + move.w CC, %ccr + roxl.b #1, DATA + move.w DATA, ADDR + UPDATE_NZC_STATUS + WRA_MEM + NEXT_OP +ROR_ACC: + move.w CC, %ccr + roxr.b #1, ACC + UPDATE_NZC_STATUS + NEXT_OP +ROR_ZP: + EA_ZP + move.b (MEMBASE,EA.w), DATA + move.w CC, %ccr + roxr.b #1, DATA + move.w DATA, ADDR + UPDATE_NZC_STATUS + move.w ADDR, DATA + move.b DATA, (MEMBASE,EA.w) + NEXT_OP +ROR_ZP_X: + EA_ZP_X + move.b (MEMBASE,EA.w), DATA + move.w CC, %ccr + roxr.b #1, DATA + move.w DATA, ADDR + UPDATE_NZC_STATUS + move.w ADDR, DATA + move.b DATA, (MEMBASE,EA.w) + NEXT_OP +ROR_ABS: + EA_ABS + RD_MEM + move.w CC, %ccr + roxr.b #1, DATA + move.w DATA, ADDR + UPDATE_NZC_STATUS + WRA_MEM + NEXT_OP +ROR_ABS_X: + EA_ABS_X + RD_MEM + move.w CC, %ccr + roxr.b #1, DATA + move.w DATA, ADDR + UPDATE_NZC_STATUS + WRA_MEM + NEXT_OP +/* + * Execute 6502 instructions for # of clocks. + */ +.global run6502 +run6502: + movem.l #0x7FFE, -(%sp) /* Save all registers */ + movem.l STATE_6502_2(GLOBAL), #0x1FFC /* Load 6502 state */ + clr.l DATA + sub.l ADDR, ADDR + move.l 60(%sp), INSTRNS /* Load instruction count */ + NEXT_OP +opfetch: + clr.w DATA + move.b (PC)+, DATA /* Load opcode */ + add.w DATA, DATA + move.w (OPBASE, DATA.w), ADDR + jmp 2(%pc,ADDR.w) +exit6502: /* This MUST follow the previous*/ + movem.l #0x1FFC, STATE_6502_2(GLOBAL) /* jmp from opfetch */ + movem.l (%sp)+, #0x7FFE + clr.l %d0 + rts + +#define OP_OFFSET(op) ((op)-exit6502) + +/* + * Initialize the CPU state and opcode arrays. + */ +.globl reset6502 +reset6502: + movem.l #0xFFFA, -(%sp) /* Save all registers */ + /* + * Init CPU state. + */ + move.l 60(%sp), MEMBASE /* Load Pointer to memory */ + move.l #0xFFFC, %d0 + move.w (MEMBASE,%d0.l), %d0 + rol.w #8, %d0 + move.l %d0, PC + add.l MEMBASE, PC + lea OPTABLE(0)(GLOBAL), OPBASE + move.l 64(%sp), WRMEM + move.l 68(%sp), RDMEM + move.b #CC_1_6502, STATUS_6502(GLOBAL) + clr.l ACC + clr.l X + clr.l Y + move.l #0x01FF0000, SP_CC + clr.l EA + clr.l PAGE + movem.l #0x1FFC, STATE_6502_2(GLOBAL) /* Save 6502 state */ + lea OPTABLE(0)(GLOBAL), %a0 + /* + * Set ADC and SBC based on DECIMAL flag. + */ + bsr set_bcd_ops + movem.l (%sp)+, #0x5FFF /* Restore all registers */ + rts +/* + * Update the opcode pointers based on the BCD decimal flag. + */ +set_bcd_ops: + btst #3, STATUS_6502(GLOBAL) + bne bcd_ops + move.w #OP_OFFSET(ADC_BIN_IMM), 0x69*2(OPBASE) + move.w #OP_OFFSET(ADC_BIN_ZP), 0x65*2(OPBASE) + move.w #OP_OFFSET(ADC_BIN_ZP_X), 0x75*2(OPBASE) + move.w #OP_OFFSET(ADC_BIN_ABS), 0x6D*2(OPBASE) + move.w #OP_OFFSET(ADC_BIN_ABS_X), 0x7D*2(OPBASE) + move.w #OP_OFFSET(ADC_BIN_ABS_Y), 0x79*2(OPBASE) + move.w #OP_OFFSET(ADC_BIN_IND_X), 0x61*2(OPBASE) + move.w #OP_OFFSET(ADC_BIN_IND_Y), 0x71*2(OPBASE) + move.w #OP_OFFSET(SBC_BIN_IMM), 0xE9*2(OPBASE) + move.w #OP_OFFSET(SBC_BIN_ZP), 0xE5*2(OPBASE) + move.w #OP_OFFSET(SBC_BIN_ZP_X), 0xF5*2(OPBASE) + move.w #OP_OFFSET(SBC_BIN_ABS), 0xED*2(OPBASE) + move.w #OP_OFFSET(SBC_BIN_ABS_X), 0xFD*2(OPBASE) + move.w #OP_OFFSET(SBC_BIN_ABS_Y), 0xF9*2(OPBASE) + move.w #OP_OFFSET(SBC_BIN_IND_X), 0xE1*2(OPBASE) + move.w #OP_OFFSET(SBC_BIN_IND_Y), 0xF1*2(OPBASE) + rts +bcd_ops: + move.w #OP_OFFSET(ADC_BCD_IMM), 0x69*2(OPBASE) + move.w #OP_OFFSET(ADC_BCD_ZP), 0x65*2(OPBASE) + move.w #OP_OFFSET(ADC_BCD_ZP_X), 0x75*2(OPBASE) + move.w #OP_OFFSET(ADC_BCD_ABS), 0x6D*2(OPBASE) + move.w #OP_OFFSET(ADC_BCD_ABS_X), 0x7D*2(OPBASE) + move.w #OP_OFFSET(ADC_BCD_ABS_Y), 0x79*2(OPBASE) + move.w #OP_OFFSET(ADC_BCD_IND_X), 0x61*2(OPBASE) + move.w #OP_OFFSET(ADC_BCD_IND_Y), 0x71*2(OPBASE) + move.w #OP_OFFSET(SBC_BCD_IMM), 0xE9*2(OPBASE) + move.w #OP_OFFSET(SBC_BCD_ZP), 0xE5*2(OPBASE) + move.w #OP_OFFSET(SBC_BCD_ZP_X), 0xF5*2(OPBASE) + move.w #OP_OFFSET(SBC_BCD_ABS), 0xED*2(OPBASE) + move.w #OP_OFFSET(SBC_BCD_ABS_X), 0xFD*2(OPBASE) + move.w #OP_OFFSET(SBC_BCD_ABS_Y), 0xF9*2(OPBASE) + move.w #OP_OFFSET(SBC_BCD_IND_X), 0xE1*2(OPBASE) + move.w #OP_OFFSET(SBC_BCD_IND_Y), 0xF1*2(OPBASE) + rts +/* + * Update to checked Program Counter range. + */ +.global setPcCheckFuncs +setPcCheckFuncs: + move.w #OP_OFFSET(BRK_CHK), OPTABLE(0x00*2)(GLOBAL) + move.w #OP_OFFSET(JSR_CHK), OPTABLE(0x20*2)(GLOBAL) + move.w #OP_OFFSET(RTI_CHK), OPTABLE(0x40*2)(GLOBAL) + move.w #OP_OFFSET(JMP_ABS_CHK), OPTABLE(0x4C*2)(GLOBAL) + move.w #OP_OFFSET(RTS_CHK), OPTABLE(0x60*2)(GLOBAL) + move.w #OP_OFFSET(JMP_IND_CHK), OPTABLE(0x6C*2)(GLOBAL) + rts +/* + * Update to unchecked Program Counter range. + */ +.global clrPcCheckFuncs +clrPcCheckFuncs: + move.w #OP_OFFSET(BRK), OPTABLE(0x00*2)(GLOBAL) + move.w #OP_OFFSET(JSR), OPTABLE(0x20*2)(GLOBAL) + move.w #OP_OFFSET(RTI), OPTABLE(0x40*2)(GLOBAL) + move.w #OP_OFFSET(JMP_ABS), OPTABLE(0x4C*2)(GLOBAL) + move.w #OP_OFFSET(RTS), OPTABLE(0x60*2)(GLOBAL) + move.w #OP_OFFSET(JMP_IND), OPTABLE(0x6C*2)(GLOBAL) + rts + +.data +.even +.global opTable6502 +opTable6502: + /* + * 0x00 - 0x0F + */ + .word OP_OFFSET(BRK) + .word OP_OFFSET(ORA_IND_X) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(TSB_ZP) + .word OP_OFFSET(ORA_ZP) + .word OP_OFFSET(ASL_ZP) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(PHP) + .word OP_OFFSET(ORA_IMM) + .word OP_OFFSET(ASL_ACC) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(TSB_ABS) + .word OP_OFFSET(ORA_ABS) + .word OP_OFFSET(ASL_ABS) + .word OP_OFFSET(UNIMPLEMENTED) + /* + * 0x10 - 0x1F + */ + .word OP_OFFSET(BPL) + .word OP_OFFSET(ORA_IND_Y) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(ORA_ZP_X) + .word OP_OFFSET(ASL_ZP_X) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(CLC) + .word OP_OFFSET(ORA_ABS_Y) + .word OP_OFFSET(INA) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(TRB_ABS) + .word OP_OFFSET(ORA_ABS_X) + .word OP_OFFSET(ASL_ABS_X) + .word OP_OFFSET(UNIMPLEMENTED) + /* + * 0x20 - 0x2F + */ + .word OP_OFFSET(JSR) + .word OP_OFFSET(AND_IND_X) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(BIT_ZP) + .word OP_OFFSET(AND_ZP) + .word OP_OFFSET(ROL_ZP) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(PLP) + .word OP_OFFSET(AND_IMM) + .word OP_OFFSET(ROL_ACC) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(BIT_ABS) + .word OP_OFFSET(AND_ABS) + .word OP_OFFSET(ROL_ABS) + .word OP_OFFSET(UNIMPLEMENTED) + /* + * 0x30 - 0x3F + */ + .word OP_OFFSET(BMI) + .word OP_OFFSET(AND_IND_Y) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(AND_ZP_X) + .word OP_OFFSET(ROL_ZP_X) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(SEC) + .word OP_OFFSET(AND_ABS_Y) + .word OP_OFFSET(DEA) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(AND_ABS_X) + .word OP_OFFSET(ROL_ABS_X) + .word OP_OFFSET(UNIMPLEMENTED) + /* + * 0x40 - 0x4F + */ + .word OP_OFFSET(RTI) + .word OP_OFFSET(EOR_IND_X) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(EOR_ZP) + .word OP_OFFSET(LSR_ZP) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(PHA) + .word OP_OFFSET(EOR_IMM) + .word OP_OFFSET(LSR_ACC) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(JMP_ABS) + .word OP_OFFSET(EOR_ABS) + .word OP_OFFSET(LSR_ABS) + .word OP_OFFSET(UNIMPLEMENTED) + /* + * 0x50 - 0x5F + */ + .word OP_OFFSET(BVC) + .word OP_OFFSET(EOR_IND_Y) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(EOR_ZP_X) + .word OP_OFFSET(LSR_ZP_X) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(CLI) + .word OP_OFFSET(EOR_ABS_Y) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(EOR_ABS_X) + .word OP_OFFSET(LSR_ABS_X) + .word OP_OFFSET(UNIMPLEMENTED) + /* + * 0x60 - 0x6F + */ + .word OP_OFFSET(RTS) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(STZ_ZP) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(ROR_ZP) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(PLA) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(ROR_ACC) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(JMP_IND) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(ROR_ABS) + .word OP_OFFSET(UNIMPLEMENTED) + /* + * 0x70 - 0x7F + */ + .word OP_OFFSET(BVS) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(ROR_ZP_X) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(SEI) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(ROR_ABS_X) + .word OP_OFFSET(UNIMPLEMENTED) + /* + * 0x80 - 0x8F + */ + .word OP_OFFSET(BRA) + .word OP_OFFSET(STA_IND_X) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(STY_ZP) + .word OP_OFFSET(STA_ZP) + .word OP_OFFSET(STX_ZP) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(DEY) + .word OP_OFFSET(BIT_IMM) + .word OP_OFFSET(TXA) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(STY_ABS) + .word OP_OFFSET(STA_ABS) + .word OP_OFFSET(STX_ABS) + .word OP_OFFSET(UNIMPLEMENTED) + /* + * 0x90 - 0x9F + */ + .word OP_OFFSET(BCC) + .word OP_OFFSET(STA_IND_Y) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(STY_ZP_X) + .word OP_OFFSET(STA_ZP_X) + .word OP_OFFSET(STX_ZP_Y) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(TYA) + .word OP_OFFSET(STA_ABS_Y) + .word OP_OFFSET(TXS) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(STZ_ABS) + .word OP_OFFSET(STA_ABS_X) + .word OP_OFFSET(STZ_ABS_X) + .word OP_OFFSET(UNIMPLEMENTED) + /* + * 0xA0 - 0xAF + */ + .word OP_OFFSET(LDY_IMM) + .word OP_OFFSET(LDA_IND_X) + .word OP_OFFSET(LDX_IMM) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(LDY_ZP) + .word OP_OFFSET(LDA_ZP) + .word OP_OFFSET(LDX_ZP) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(TAY) + .word OP_OFFSET(LDA_IMM) + .word OP_OFFSET(TAX) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(LDY_ABS) + .word OP_OFFSET(LDA_ABS) + .word OP_OFFSET(LDX_ABS) + .word exit6502-UNIMPLEMENTED + /* + * 0xB0 - 0xBF + */ + .word OP_OFFSET(BCS) + .word OP_OFFSET(LDA_IND_Y) + .word OP_OFFSET(LDA_ZP_IND) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(LDY_ZP_X) + .word OP_OFFSET(LDA_ZP_X) + .word OP_OFFSET(LDX_ZP_Y) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(CLV) + .word OP_OFFSET(LDA_ABS_Y) + .word OP_OFFSET(TSX) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(LDY_ABS_X) + .word OP_OFFSET(LDA_ABS_X) + .word OP_OFFSET(LDX_ABS_Y) + .word OP_OFFSET(UNIMPLEMENTED) + /* + * 0xC0 - 0xCF + */ + .word OP_OFFSET(CPY_IMM) + .word OP_OFFSET(CMP_IND_X) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(CPY_ZP) + .word OP_OFFSET(CMP_ZP) + .word OP_OFFSET(DEC_ZP) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(INY) + .word OP_OFFSET(CMP_IMM) + .word OP_OFFSET(DEX) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(CPY_ABS) + .word OP_OFFSET(CMP_ABS) + .word OP_OFFSET(DEC_ABS) + .word OP_OFFSET(UNIMPLEMENTED) + /* + * 0xD0 - 0xDF + */ + .word OP_OFFSET(BNE) + .word OP_OFFSET(CMP_IND_Y) + .word OP_OFFSET(CMP_ZP_IND) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(CMP_ZP_X) + .word OP_OFFSET(DEC_ZP_X) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(CLD) + .word OP_OFFSET(CMP_ABS_Y) + .word OP_OFFSET(PHX) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(CMP_ABS_X) + .word OP_OFFSET(DEC_ABS_X) + .word OP_OFFSET(UNIMPLEMENTED) + /* + * 0xE0 - 0xEF + */ + .word OP_OFFSET(CPX_IMM) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(CPX_ZP) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(INC_ZP) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(INX) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(NOP) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(CPX_ABS) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(INC_ABS) + .word OP_OFFSET(UNIMPLEMENTED) + /* + * 0xF0 - 0xFF + */ + .word OP_OFFSET(BEQ) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(INC_ZP_X) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(SED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(PLX) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(UNIMPLEMENTED) + .word OP_OFFSET(INC_ABS_X) + .word OP_OFFSET(UNIMPLEMENTED) +.even +.comm state6502, 13*4 +.comm status6502, 1 + diff --git a/src/6502.h b/src/6502.h new file mode 100755 index 0000000..cb01169 --- /dev/null +++ b/src/6502.h @@ -0,0 +1,117 @@ +UInt32 run6502(UInt32); +void reset6502(UInt8 *, WRITEBYTE *, READBYTE *); +void setPcCheckFuncs(void); +void clrPcCheckFuncs(void); +extern UInt16 opTable6502[256]; +extern union state6502_t +{ + struct + { + UInt32 DATA; /* D0 */ + UInt32 INST; /* D1 */ + UInt32 ACC; /* D2 */ + UInt32 X; /* D3 */ + UInt32 Y; /* D4 */ + UInt32 SP_CC; /* D5 */ + UInt32 EA; /* D6 */ + UInt32 PAGE; /* D7 */ + UInt32 PC; /* A0 */ + UInt32 OPBASE; /* A1 */ + UInt32 MEMBASE;/* A2 */ + UInt32 WRMEM; /* A3 */ + UInt32 RDMEM; /* A4 */ + UInt32 ADDR; /* A6 */ + } LongRegs; + struct + { + UInt16 Filler0; + UInt16 DATA; /* D0 */ + UInt16 INSTHI; + UInt16 INSTLO; /* D1 */ + UInt16 Filler1; + UInt16 ACC; /* D2 */ + UInt16 Filler2; + UInt16 X; /* D3 */ + UInt16 Filler3; + UInt16 Y; /* D4 */ + UInt16 SP; + UInt16 CC; /* D5 */ + UInt16 Filler5; + UInt16 EA; /* D6 */ + UInt16 Filler6; + UInt16 PAGE; /* D7 */ + UInt16 Filler7; + UInt16 PC; /* A0 */ + UInt16 Filler8; + UInt16 OPBASE; /* A1 */ + UInt16 Filler9; + UInt16 MEMBASE;/* A2 */ + UInt16 Filler10; + UInt16 WRMEM; /* A3 */ + UInt16 Filler11; + UInt16 RDMEM; /* A4 */ + UInt16 Filler12; + UInt16 ADDR; /* A6 */ + } WordRegs; + struct + { + UInt8 Filler0; + UInt8 Filler1; + UInt8 Filler2; + UInt8 DATA; /* D0 */ + UInt8 INST3; + UInt8 INST2; + UInt8 INST1; + UInt8 INST0; /* D1 */ + UInt8 Filler3; + UInt8 Filler4; + UInt8 Filler5; + UInt8 ACC; /* D2 */ + UInt8 Filler6; + UInt8 Filler7; + UInt8 Filler8; + UInt8 X; /* D3 */ + UInt8 Filler9; + UInt8 Filler10; + UInt8 Filler11; + UInt8 Y; /* D4 */ + UInt8 SPHI; + UInt8 SPLO; + UInt8 Filler14; + UInt8 CC; /* D5 */ + UInt8 Filler18; + UInt8 Filler19; + UInt8 Filler20; + UInt8 EA; /* D6 */ + UInt8 Filler21; + UInt8 Filler22; + UInt8 Filler23; + UInt8 PAGE; /* D7 */ + UInt8 Filler24; + UInt8 Filler25; + UInt8 PCHI; /* A0 */ + UInt8 PCLO; /* A0 */ + UInt8 Filler26; + UInt8 Filler27; + UInt8 OPBASEHI;/* A1 */ + UInt8 OPBASELO;/* A1 */ + UInt8 Filler28; + UInt8 Filler29; + UInt8 MEMBASEHI;/* A2 */ + UInt8 MEMBASELO;/* A2 */ + UInt8 Filler30; + UInt8 Filler31; + UInt8 WRMEM; /* A3 */ + UInt8 WRMEMLO; /* A3 */ + UInt8 Filler32; + UInt8 Filler33; + UInt8 RDMEM; /* A4 */ + UInt8 RDMEMLO; /* A4 */ + UInt8 Filler34; + UInt8 Filler35; + UInt8 ADDRHI; /* A6 */ + UInt8 ADDRLO; /* A6 */ + } ByteRegs; +} state6502; +extern UInt8 status6502; + diff --git a/src/Apple2.h b/src/Apple2.h new file mode 100755 index 0000000..6f29bc6 --- /dev/null +++ b/src/Apple2.h @@ -0,0 +1,193 @@ +#include "memory.h" +#include "6502.h" +#include "iou.h" +#define GRMODE_MONO 0 +#define GRMODE_COLOR 1 +#define GRMODE_SONYHR_MONO 2 +#define GRMODE_SONYHR_COLOR 3 +#define GRMODE_OS5HR_MONO 4 +#define GRMODE_OS5HR_COLOR 5 +#define CLRMODE_INTERP 0 +#define CLRMODE_STD 1 +#define GRMODE_ISCOLOR(m) ((m)&1) +#ifdef DEBUG +#define Apple2Run(c) \ +do { \ + static UInt8 *PC_6502,*prevPC_6502;\ + UInt16 i; \ + UInt32 badop; \ + MemSemaphoreReserve(true);\ + for(i=(c); i; i--) { \ + prevPC_6502 = PC_6502;\ + PC_6502 = (UInt8*)state6502.LongRegs.PC;\ + badop = run6502(1); \ + if (badop) { \ + Char string[40]; \ + Apple2Pause(true); \ + StrPrintF(string, "Bad opcode 0x%02x @ 0x%04x", (UInt16)badop, (UInt16)(badop >> 16)); \ + WinDrawChars(string, StrLen(string), 15, 140); \ + StrPrintF(string, "Prev opcode 0x%02x @ 0x%04x", (UInt16)*prevPC_6502, (UInt16)(prevPC_6502 - AppleMemory)); \ + WinDrawChars(string, StrLen(string), 15, 150);\ + break; \ + } \ + } \ + MemSemaphoreRelease(true);\ +} while(0) +#else +#define Apple2Run(c) \ +do { \ + UInt32 badop; \ + MemSemaphoreReserve(true);\ + badop = run6502((c)); \ + MemSemaphoreRelease(true);\ + if (badop) {\ + Char string[40]; \ + if (!prefs.ignoreBadOps){ \ + Apple2Pause(true); \ + StrPrintF(string, "Bad opcode 0x%02x @ 0x%04x", (UInt16)badop, (UInt16)(badop >> 16)); \ + WinDrawChars(string, StrLen(string), 15, 140); \ + } \ + state6502.LongRegs.PC++;\ + } \ +} while(0) +#endif + +#define Apple2UpdateVideo() \ +do { \ + if (dirtyVideo){ \ + if (dirtyVideo > 1) \ + setVideoFuncs(false); \ + updateVideo(); \ + } \ +} while(0) + +#if CLIE_SOUND +#define Apple2UpdateAudio() \ +do { \ + if (AppleVolume) { \ + if (refPa1) { \ + static UInt32 lastFreq=0; \ + Boolean retval; \ + if (spkrIOU) { \ + lastFreq=spkrIOU >> 4; \ + PA1L_midiNoteOn(refPa1,hMidi,0,lastFreq,127,&retval);\ + spkrIOU=0; \ + } \ + else if (lastFreq) { \ + PA1L_midiNoteOff(refPa1,hMidi,0,lastFreq,1,&retval);\ + lastFreq=0; \ + } \ + } \ + else if (spkrIOU) { \ + SndCommandType sndCmd; \ + sndCmd.cmd = sndCmdFreqDurationAmp;\ + sndCmd.param1 = ((UInt32)spkrIOU)/*Hz*/;\ + sndCmd.param2 = 20/*msec*/; \ + sndCmd.param3 = AppleVolume; \ + SndDoCmd(0, &sndCmd, true/*noWait*/);\ + spkrIOU = 0; \ + } \ + } \ +} while(0) +#else +#define Apple2UpdateAudio() \ +do { \ + if (AppleVolume) { \ + static UInt32 lastFreq=0; \ + SndCommandType sndCmd; \ + if (spkrIOU) { \ + lastFreq=spkrIOU*A2Hz/prefs.refreshRate;\ + sndCmd.cmd = sndCmdFrqOn;\ + sndCmd.param1 = lastFreq/*Hz*/;\ + sndCmd.param2 = 20/*msec*/; \ + sndCmd.param3 = AppleVolume;\ + SndDoCmd(0, &sndCmd, true/*noWait*/);\ + spkrIOU=0; \ + } \ + else if (lastFreq) { \ + sndCmd.cmd = sndCmdQuiet;\ + sndCmd.param1 = 0/*Hz*/; \ + sndCmd.param2 = 0/*msec*/; \ + sndCmd.param3 = AppleVolume;\ + SndDoCmd(0, &sndCmd, true/*noWait*/);\ + lastFreq=0; \ + } \ + } \ +} while(0) +#endif + +#define Apple2PutKey(key) \ +do { \ + UInt8 keyCode; \ + if (kbdCount < KBD_BUF_SIZE) { \ + if (keyCtrlMod && TxtCharIsAlpha(key)) { \ + keyCode = 0x80 | (TxtCharIsLower(key) ? ((key) - 'a' + 1) : ((key) - 'A' + 1));\ + if (keyCode == 0x83) kbdCount = 0; \ + } else if (prefs.capsLock && TxtCharIsAlpha(key) && TxtCharIsLower(key)) {\ + keyCode = 0x80 | (key) - 'a' + 'A'; \ + } else { \ + keyCode = 0x80 | (key); \ + } \ + if (kbdCount++) \ + kbdBuffer[(kbdHead + kbdCount - 1) \ + & KBD_BUF_MASK] = keyCode; \ + else \ + kbdIOU = keyCode; \ + } \ + keyCtrlMod = false; \ +} while (0) +#define Apple2PutKeyNonAlpha(key) \ +do { \ + UInt8 keyCode; \ + if (kbdCount < KBD_BUF_SIZE) { \ + keyCode = 0x80 | (key); \ + if (kbdCount++) \ + kbdBuffer[(kbdHead + kbdCount - 1) \ + & KBD_BUF_MASK] = keyCode; \ + else \ + kbdIOU = keyCode; \ + } \ + keyCtrlMod = false; \ +} while (0) + +#define Apple2GetKey() (kbdIOU = ((kbdCount) ? kbdBuffer[(kbdHead + --kbdCount) & KBD_BUF_MASK] : kbdIOU & 0x7F)) +extern UInt32 AppleInstrCount; +extern UInt32 AppleInstrInc; +/* + * Preferences. + */ +#define PREFS_VERSION 0x00000013L +struct _prefs_t +{ + UInt32 version; + UInt32 state6502_ACC; + UInt32 state6502_X; + UInt32 state6502_Y; + UInt32 state6502_SP_CC; + UInt32 state6502_PC; + UInt8 status6502; + UInt16 memIOU; + UInt16 vidIOU; + Char currentDsk[2][32]; + Char writeEnable[2]; + UInt16 currentTrack[2]; + UInt16 currentPos[2]; + UInt8 currentDrive; + Boolean currentMotor; + Boolean ignoreBadOps; + Boolean muteSound; + Boolean enable80Col; + Boolean capsLock; + UInt8 refreshRate; + UInt32 keyHardMask; + UInt16 keyHard1; + UInt16 keyHard2; + UInt16 keyHard3; + UInt16 keyHard4; + UInt8 centerJoystickHorizPos; + UInt8 centerJoystickVertPos; + UInt8 centerJoystickRate; + UInt8 moveJoystickRate; +}; +extern struct _prefs_t prefs; + diff --git a/src/a2mgr.c b/src/a2mgr.c new file mode 100755 index 0000000..208ec99 --- /dev/null +++ b/src/a2mgr.c @@ -0,0 +1,219 @@ +#include +#include "a2mgr_rsc.h" +/* + * Globals. + */ + +/*****************************************************************************\ +* * +* Utility Routines * +* * +\*****************************************************************************/ + +/*****************************************************************************\ +* * +* Forms * +* * +\*****************************************************************************/ + +/* + * Form UI elements helper routines. + */ +static void *GetObjectPtr(UInt16 objectID) +{ + FormType *form = FrmGetActiveForm(); + return (FrmGetObjectPtr(form, FrmGetObjectIndex(form, objectID))); +} +static void FieldSetValue(FieldType *field, UInt16 value) +{ + Char *mem; + MemHandle hMem = FldGetTextHandle(field); + FldSetTextHandle(field, NULL); + if (hMem) + MemHandleFree(hMem); + hMem = MemHandleNew(8); + mem = MemHandleLock(hMem); + StrPrintF(mem, "%d", value); + MemHandleUnlock(hMem); + FldSetTextHandle(field, hMem); +} +static void FieldSpin(FieldType *field, Int16 spin, Int16 min, Int16 max) +{ + MemHandle hMem; + Char *mem; + Int16 tmp; + + hMem = FldGetTextHandle(field); + FldSetTextHandle(field, NULL); + mem = MemHandleLock(hMem); + tmp = StrAToI(mem); + if (spin > 0) + { + if ((Int32)(tmp + spin) > (Int32)max) + tmp = max; + else + tmp += spin; + } + else + { + if ((Int32)(tmp + spin) < (Int32)min) + tmp = min; + else + tmp += spin; + } + StrPrintF(mem, "%d", tmp); + MemHandleUnlock(hMem); + FldSetTextHandle(field, hMem); + FldDrawField(field); +} +/* + * Dsk Image Manager Form. + */ +char currentDsk[2][32]; +static Boolean DskManagerHandleEvent(EventType *event) +{ + static Int16 numDsks; + static Char **nameDsks; + static EventType stopEvent; + Int16 i, cardNo, otherDiskDrive, LoadDiskDrive=1; + UInt32 dbType; + DmSearchStateType searchState; + LocalID dbID; + Char name[33]; + Boolean first, handled = false; + switch (event->eType) + { + case frmOpenEvent: + /* + * Look for VFS volumes. + */ + + /* + * Scan databases for disk images. + */ + first = true; + numDsks = 0; + while (!DmGetNextDatabaseByTypeCreator(first, &searchState, NULL, 'Apl2', false, &cardNo, &dbID)) + { + first = false; + DmDatabaseInfo(cardNo, dbID, name, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &dbType, NULL); + if (dbType == 'RDSK' || dbType == 'DDSK') + numDsks++; + } + first = true; + nameDsks = MemPtrNew(numDsks * sizeof(Char *)); + nameDsks[0] = MemPtrNew(8); + numDsks = 0; + while (!DmGetNextDatabaseByTypeCreator(first, &searchState, NULL, 'Apl2', false, &cardNo, &dbID)) + { + first = false; + DmDatabaseInfo(cardNo, dbID, name, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &dbType, NULL); + if (dbType == 'RDSK' || dbType == 'DDSK') + { + nameDsks[numDsks] = MemPtrNew(32); + StrCopy(nameDsks[numDsks], name); + numDsks++; + } + } + LstSetListChoices(GetObjectPtr(lstDsk), nameDsks, numDsks); + FrmDrawForm(FrmGetActiveForm()); + handled = true; + break; + case ctlSelectEvent: + switch (event->data.ctlSelect.controlID) + { + case buttonExit: + { + UInt32 dbid, retval; + if ((dbid = DmFindDatabase(0, "Appalm ]["))) + SysUIAppSwitch(0, dbid, sysAppLaunchCmdNormalLaunch, NULL); + else + { + stopEvent.eType = appStopEvent; + EvtAddEventToQueue(&stopEvent); + } + } + break; + } + break; + } + return (handled); +} +/*****************************************************************************\ +* * +* Application start/stop/main routines * +* * +\*****************************************************************************/ + +static Boolean AppStart(void) +{ + /* + * Goto main form. + */ + FrmGotoForm(DskMgrForm); + return (true); +} +static void AppStop(void) +{ +} +static Boolean AppProcessEvent(EventType *event) +{ + UInt16 error; + FormType *frm; + + if (!SysHandleEvent(event) && !MenuHandleEvent(0, event, &error)) + { + /* + * Application specific event. + */ + if (event->eType == frmLoadEvent) + { + /* + * Load the form resource specified in the event then activate the form. + */ + frm = FrmInitForm(event->data.frmLoad.formID); + FrmSetActiveForm(frm); + /* + * Set the event handler for the form. The handler of the currently + * active form is called by FrmDispatchEvent each time it receives an event. + */ + switch (event->data.frmLoad.formID) + { + case DskMgrForm: + FrmSetEventHandler(frm, DskManagerHandleEvent); + break; + } + } + else + /* + * Pass it on to the form handler. + */ + FrmDispatchEvent(event); + } + return (event->eType != appStopEvent); +} +/* + * Main. + */ +UInt32 PilotMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) +{ + UInt16 error; + EventType event; + + if (cmd == sysAppLaunchCmdNormalLaunch) + { + if (AppStart()) + { + /* + * Main event loop. + */ + do + { + EvtGetEvent(&event, evtWaitForever); + } while (AppProcessEvent(&event)); + AppStop(); + } + } + return(0); +} + diff --git a/src/a2mgr.rcp b/src/a2mgr.rcp new file mode 100755 index 0000000..21331d5 --- /dev/null +++ b/src/a2mgr.rcp @@ -0,0 +1,38 @@ +#include "a2mgr_rsc.h" + +VERSION ID 1000 "1.0" + +// +// DskMgr resources. +// + +FORM ID DskMgrForm AT (0 0 160 160) +BEGIN + TITLE "Dsk Image Manager" + LIST "" ID lstDsk AT (10 22 110 68) + CHECKBOX "Reset After Load" ID checkReset AT (10 95 AUTO AUTO) FONT 1 + BUTTON "EXIT" ID buttonExit AT (10 110 AUTO AUTO) +END + +ALERT ID MessageBox +INFORMATION +BEGIN + TITLE "Message" + MESSAGE "^1" + BUTTONS "OK" +END + +ALERT ID AboutBox +INFORMATION +BEGIN + TITLE "About" + MESSAGE "Appalm ][ Manager\npalmapple.sourceforge.net" + BUTTONS "OK" +END + +ICONFAMILY 1000 "icons/ApPalm_32x22_B&W.bmp" "icons/ApPalm_32x22_B&W.bmp" "icons/ApPalm_32x22_4grey.bmp" "icons/ApPalm_32x22_256.bmp" TRANSPARENT 255 0 255 + +SMALLICONFAMILY 1001 "icons/ApPalm_15x9_B&W.bmp" "icons/ApPalm_15x9_B&W.bmp" "icons/ApPalm_15x9_4grey.bmp" "icons/ApPalm_15x9_256.bmp" TRANSPARENT 255 0 255 + + + diff --git a/src/a2mgr_rsc.h b/src/a2mgr_rsc.h new file mode 100755 index 0000000..ffd2e3e --- /dev/null +++ b/src/a2mgr_rsc.h @@ -0,0 +1,19 @@ +// Resource: tFRM 1000 +#define DskMgrForm 9000 + +// Resource: Talt 2500 +#define AboutBox 9100 + +// Resource: Talt 2600 +#define MessageBox 9200 +#define MesageOK 9201 + +// +// ButtonIDs +#define buttonExit 1000 + +// LoadDisk UI IDs +#define lstDsk 1010 +#define checkReset 1011 + + diff --git a/src/appalm.c b/src/appalm.c new file mode 100755 index 0000000..2370c3b --- /dev/null +++ b/src/appalm.c @@ -0,0 +1,1250 @@ +#include +#include +#define keyBitGameExt0 0x00010000L // SONY GameController Extension bit0 +#define keyBitGameExt1 0x00020000L // SONY GameController Extension bit1 +#define KEY_MASK_ALL (~(keyBitPageUp | keyBitPageDown | keyBitHard1 | keyBitHard2 | keyBitHard3 | keyBitHard4 | keyBitGameExt0 | keyBitGameExt1)) +#define KEY_MASK_BTTNS (~(keyBitHard1 | keyBitHard4 | keyBitGameExt0 | keyBitGameExt1)) +#include "Apple2.h" +#include "appalm_rsc.h" +#define ROM_VERSION_2_0 0x02000000L +#define ROM_VERSION_3_1 0x03100000L +#define ROM_VERSION_3_5 0x03500000L +#ifdef CLIE_SOUND +#include "Pa1Lib.h" +#define sonySysFtrNumSystemBase 10000 +#define sonySysFtrNumSystemAOutSndStateOnHandlerP (sonySysFtrNumSystemBase + 4) +#define sonySysFtrNumSystemAOutSndStateOffHandlerP (sonySysFtrNumSystemBase + 5) +#define aOutSndKindSp (0) /* speaker */ +#define aOutSndKindHp (2) /* headphone */ +#define ADPCM_MODE_NONCONTINUOUS_PB 0x01 +#define ADPCM_MODE_INTERRUPT_MODE 0x02 +#define ADPCM_4_KHZ 0 +#define ADPCM_8_KHZ 1 +#define appStopSoundEvent firstUserEvent +typedef void (*sndStateOnType)(UInt8 /* kind */, + UInt8 /* left volume 0-31 */, + UInt8 /* right volume 0-31 */); +typedef void (*sndStateOffType)(UInt8 /* kind */); +#endif +/* + * Globals. + */ +struct _prefs_t prefs; +UInt32 romVersion; +UInt16 grMode; +UInt16 refHR, refSnd, refPa1; +UInt8 hMidi; +UInt16 AppleVolume, A2Hz; +UInt32 jogBits; +UInt16 **jogAstMaskP; +UInt16 *jogAstOldMask; +UInt16 jogAstMask[2]; +Char Title[50]; +Boolean pause = false; +Boolean keyCtrlMod = false; +UInt8 LoadDiskDrive; +UInt32 AppleInstrCount; +UInt32 AppleInstrInc; +static void Apple2Pause(Boolean); + +/*****************************************************************************\ +* * +* Utility Routines * +* * +\*****************************************************************************/ + +/* + * ROM version check. + */ +static Err RomVersionCompatible(UInt32 requiredVersion, UInt16 launchFlags) +{ + UInt32 localRomVersion; + FtrGet(sysFtrCreator, sysFtrNumROMVersion, &localRomVersion); + if (sysAppLaunchCmdNormalLaunch) + romVersion = localRomVersion; + if (localRomVersion < requiredVersion) + { + if ((launchFlags & (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp)) == (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp)) + { + FrmAlert(RomIncompatibleAlert); + /* + * Pilot 1.0 will continuously relaunch this app unless we switch to + * another safe one. The sysFileCDefaultApp is considered "safe". + */ + if (localRomVersion < ROM_VERSION_2_0) + AppLaunchWithCommand(sysFileCDefaultApp, sysAppLaunchCmdNormalLaunch, NULL); + } + return (sysErrRomIncompatible); + } + return (0); +} +/* + * Sony HIRES routines. + */ +void GrSetMode(void) +{ + Err error; + UInt32 width, height, depth; + Boolean colorMode; + + switch (grMode) + { + case GRMODE_MONO: + depth = 2; width = height = 160; + WinScreenMode(winScreenModeSet, &width, &height, &depth, NULL); + break; + case GRMODE_COLOR: + depth = 8; width = height = 160; + WinScreenMode(winScreenModeSet, &width, &height, &depth, NULL); + break; +// case GRMODE_SONYHR_MONO: + case GRMODE_SONYHR_COLOR: + error = HROpen(refHR); + if (!error) + { + width = hrWidth; height = hrHeight; depth = 8;//(grMode == GRMODE_SONYHR_COLOR) ? 8 : 1; + HRWinScreenMode(refHR, winScreenModeSet, &width, &height, &depth, NULL); + } + else + { + WinScreenMode(winScreenModeSet, NULL, NULL, &depth, NULL); + grMode = GRMODE_MONO; + } + break; +// case GRMODE_OS5HR_MONO: +// depth = 1; width = 320; +// WinScreenMode(winScreenModeSet, &width, NULL, &depth, NULL); +// break; + case GRMODE_OS5HR_COLOR: + depth = 8; width = 320; colorMode = true; + WinScreenMode(winScreenModeSet, &width, NULL, &depth, NULL/*&colorMode*/); + break; + } +} +void GrSetDefaultMode(void) +{ + switch (grMode) + { + case GRMODE_MONO: + case GRMODE_COLOR: + WinScreenMode(winScreenModeSetToDefaults, NULL, NULL, NULL, NULL); + break; + case GRMODE_SONYHR_MONO: + case GRMODE_SONYHR_COLOR: + HRWinScreenMode (refHR, winScreenModeSetToDefaults, NULL, NULL, NULL, NULL); + HRClose(refHR); + break; + case GRMODE_OS5HR_MONO: + case GRMODE_OS5HR_COLOR: + WinScreenMode(winScreenModeSetToDefaults, NULL, NULL, NULL, NULL); + break; + } +} +#ifdef CLIE_SOUND +static void SonySetVolume(UInt16 pa1LibRefNum, UInt8 volume) +{ + Boolean successful; + + // the sndState function pointers must be called to initialize + // sound playback properly + if (volume) + { + sndStateOnType sndStateOnFuncP; + if (FtrGet(sonySysFileCSystem, sonySysFtrNumSystemAOutSndStateOnHandlerP, (UInt32*) &sndStateOnFuncP) == errNone) + { + sndStateOnFuncP(aOutSndKindSp, volume, volume); + sndStateOnFuncP(aOutSndKindHp, volume, volume); + } + PA1L_devSpVolume(pa1LibRefNum, volume, &successful); + PA1L_devHpVolume(pa1LibRefNum, volume, volume, &successful); + } + else + { + sndStateOffType sndStateOffFuncP; + if (FtrGet(sonySysFileCSystem, sonySysFtrNumSystemAOutSndStateOffHandlerP, (UInt32*) &sndStateOffFuncP) == errNone) + { + sndStateOffFuncP(aOutSndKindSp); + sndStateOffFuncP(aOutSndKindHp); + } + } +} +#endif +/* + * Drive gadgets. + */ +void showDiskName(UInt16 drive_no, Char *diskname) +{ + RectangleType rect; + + WinSetDrawWindow(WinGetDisplayWindow()); + if (grMode > GRMODE_COLOR) + { + rect.topLeft.x = (drive_no == 1 ? 0 : 80) + 2; + rect.topLeft.y = 125; + rect.extent.x = 76; + rect.extent.y = 11; + WinSetForeColor(0); + WinSetTextColor(0); + WinSetBackColor(216); + } + else + { + rect.topLeft.x = 80; + rect.topLeft.y = 0; + rect.extent.x = 80; + rect.extent.y = 10; + } + WinSetClip(&rect); + WinEraseRectangle(&rect, 0); + WinDrawChars(diskname, StrLen(diskname), rect.topLeft.x, rect.topLeft.y); + WinResetClip(); +} +void showDriveState(UInt16 drive_no, Boolean motor_on) +{ + static UInt16 spin = 0; + RectangleType rect; + + WinSetDrawWindow(WinGetDisplayWindow()); + if (grMode > GRMODE_COLOR) + { + rect.topLeft.x = drive_no == 1 ? 70 : 150; + rect.topLeft.y = 150; + rect.extent.x = 5; + rect.extent.y = 5; + WinSetForeColor(motor_on ? 125 : 197); + WinDrawRectangle(&rect, 0); + } + else + { + if (motor_on) + WinDrawChars(spin++ & 1 ? "+" : "x", 1, 70, 0); + else + WinDrawChars(" ", 3, 70, 0); + } +} +void showDrive(UInt16 id, RectangleType *gadgetRect) +{ + RectangleType rect; + + WinSetDrawWindow(WinGetDisplayWindow()); + WinSetForeColor(0); + WinSetTextColor(0); + WinSetBackColor(216); + WinEraseRectangle(gadgetRect, 0); + WinDrawRectangleFrame(dialogFrame, gadgetRect); + rect.extent.x = gadgetRect->extent.x - 10; + rect.extent.y = 2; + rect.topLeft.x = gadgetRect->topLeft.x + (gadgetRect->extent.x - rect.extent.x) / 2; + rect.topLeft.y = gadgetRect->topLeft.y + (gadgetRect->extent.y - rect.extent.y) / 2; + WinDrawRectangleFrame(rectangleFrame, &rect); + rect.extent.x = 20; + rect.extent.y = 8; + rect.topLeft.x = gadgetRect->topLeft.x + (gadgetRect->extent.x - rect.extent.x) / 2; + rect.topLeft.y = gadgetRect->topLeft.y + (gadgetRect->extent.y - rect.extent.y) / 2; + WinEraseRectangle(&rect, 0); + WinDrawRectangleFrame(rectangleFrame, &rect); + WinDrawChars(id == gadgetDrive1 ? "Drive 1" : "Drive 2", 7, gadgetRect->topLeft.x + 2, gadgetRect->topLeft.y + 23); +} +Boolean DriveHandleEvent(struct FormGadgetTypeInCallback *gadget, UInt16 cmd, void *param) +{ + static UInt16 penX, penY; + Boolean handled = false; + + if (cmd == formGadgetDrawCmd) + { + showDrive(gadget->id, &(gadget->rect)); + gadget->attr.usable = true; + gadget->attr.extended = true; + gadget->attr.visible = true; + handled = true; + } + else if (cmd == formGadgetHandleEventCmd) + { +#if 0 + EventType *event = param; + WinSetDrawWindow(WinGetDisplayWindow()); + WinInvertRectangle(&(gadget->rect), 0); + switch (event->eType) + { + case frmUpdateEvent: + showDrive(gadget->id, &(gadget->rect)); + handled = true; + break; + case penDownEvent: + penX = event->screenX; + penY = event->screenY; + handled = true; + break; + case penMoveEvent: + penX = ~0; + penY = ~0; + handled = true; + break; + case penUpEvent: + if ((penX == event->screenX) && (penY == event->screenY)) + { + LoadDiskDrive = (gadget->id == gadgetDrive1) ? 1 : 2; + FrmPopupForm(LoadDiskForm); + } + handled = true; + break; + } +#else + LoadDiskDrive = (gadget->id == gadgetDrive1) ? 1 : 2; + FrmPopupForm(LoadDiskForm); + Apple2Pause(true); +#endif + } + return (handled); +} + +/*****************************************************************************\ +* * +* Forms * +* * +\*****************************************************************************/ + +/* + * Menu. + */ +static void Apple2Pause(Boolean Pause) +{ + pause = Pause; + FrmSetTitle(FrmGetActiveForm(), pause ? "(paused)" : Title); + WinSetDrawWindow(WinGetDisplayWindow()); +} +static void Apple2MenuSetItems(void) +{ + if (prefs.ignoreBadOps) + MenuHideItem(menuIgnoreBadOps); + if (grMode > GRMODE_COLOR) + { + if (prefs.enable80Col) + { + MenuHideItem(menuEnable80Col); + MenuShowItem(menuDisable80Col); + } + else + { + MenuHideItem(menuDisable80Col); + MenuShowItem(menuEnable80Col); + } + } + else + { + MenuHideItem(menuDisable80Col); + MenuHideItem(menuEnable80Col); + } + if (prefs.capsLock) + { + MenuHideItem(menuCapsLock); + MenuShowItem(menuCapsUnlock); + } + else + { + MenuHideItem(menuCapsUnlock); + MenuShowItem(menuCapsLock); + } + if (prefs.muteSound) + { + MenuHideItem(menuMuteSound); + MenuShowItem(menuUnmuteSound); + } + else + { + MenuHideItem(menuUnmuteSound); + MenuShowItem(menuMuteSound); + } + if (prefs.keyHardMask == KEY_MASK_ALL) + { + MenuHideItem(menuEnableJoystick); + MenuShowItem(menuDisableJoystick); + } + else + { + MenuHideItem(menuDisableJoystick); + MenuShowItem(menuEnableJoystick); + } + if (DmFindDatabase(0, "A2 Manager")) + MenuShowItem(menuA2Manager); + else + MenuHideItem(menuA2Manager); +} +static Boolean Apple2MenuHandleEvent(UInt16 menuID) +{ + Char string[20]; + Boolean pause = false; + + switch (menuID) + { + case menuLoadDisk1: + LoadDiskDrive = 1; + FrmPopupForm(LoadDiskForm); + pause = true; + break; + case menuLoadDisk2: + LoadDiskDrive = 2; + FrmPopupForm(LoadDiskForm); + pause = true; + break; + case menuA2Manager: + { + UInt32 dbid; + if ((dbid = DmFindDatabase(0, "A2 Manager"))) + SysUIAppSwitch(0, dbid, sysAppLaunchCmdNormalLaunch, NULL); + else + FrmCustomAlert(MessageBox, "Appalm ][ Manager not available", NULL, NULL); + } + break; + case menuESC: + kbdCount = 0; + Apple2PutKeyNonAlpha(27); + break; + case menuCTRL: + keyCtrlMod = true; + break; + case menuCapsLock: + case menuCapsUnlock: + prefs.capsLock = !prefs.capsLock; + Apple2MenuSetItems(); + break; + case menuFlushKbdBuf: + kbdCount = 0; + kbdIOU &= 0x7F; + break; + case menuDisableJoystick: + prefs.keyHardMask = KEY_MASK_BTTNS; + KeySetMask(prefs.keyHardMask); + Apple2MenuSetItems(); + break; + case menuEnableJoystick: + prefs.keyHardMask = KEY_MASK_ALL; + KeySetMask(prefs.keyHardMask); + Apple2MenuSetItems(); + break; + case menuJoystickSettings: + FrmPopupForm(JoystickSettingsForm); + pause = true; + break; + case menuIncRefresh: + if (prefs.refreshRate > 1) + prefs.refreshRate--; + else + prefs.refreshRate = 1; + AppleInstrInc = prefs.refreshRate * 5000; + break; + case menuDecRefresh: + AppleInstrInc = ++prefs.refreshRate * 5000; + break; + case menuDisable80Col: + case menuEnable80Col: + prefs.enable80Col = !prefs.enable80Col; + Apple2MenuSetItems(); + break; + case menuMuteSound: + prefs.muteSound = true; + AppleVolume = 0; + Apple2MenuSetItems(); + break; + case menuUnmuteSound: + prefs.muteSound = false; + spkrIOU = 0; + AppleVolume = PrefGetPreference(prefGameSoundVolume); + Apple2MenuSetItems(); + break; + case menuUnpause: + break; + case menuPause: + Apple2Pause(true); + pause = true; + break; + case menuReset: + MemSemaphoreReserve(true); + initMemory(); + initVideo(); + resetDisks(); + reset6502(AppleMemory, WriteFunction, ReadFunction); + MemSemaphoreRelease(true); + break; + case menuIgnoreBadOps: + prefs.ignoreBadOps = true; + Apple2MenuSetItems(); + break; + case menuAbout: + Apple2Pause(true); + FrmAlert(AboutBox); + break; + } + Apple2Pause(pause); + return (true); +} +/* + * Main form. + */ +static Boolean Apple2HandleEvent(EventType *event) +{ + static FormType *frmApple2; + RectangleType rect; + Boolean handled = false; + switch (event->eType) + { + case keyDownEvent: + if (event->data.keyDown.modifiers & controlKeyMask) + keyCtrlMod = true; + switch (event->data.keyDown.chr) + { + case vchrJogPushedUp: + jogBits = keyBitHard1; + case vchrJogUp: + pdlResetIOU[0] += prefs.moveJoystickRate; + if (pdlResetIOU[0] > 0xFF) + pdlResetIOU[0] = 0xFF; + handled = true; + break; + case vchrJogPushedDown: + jogBits = keyBitHard1; + case vchrJogDown: + pdlResetIOU[0] -= prefs.moveJoystickRate; + if (pdlResetIOU[0] > 0xFF) + pdlResetIOU[0] = 0x00; + handled = true; + break; + case vchrJogPush: + jogBits = keyBitHard1; + handled = true; + break; + case vchrJogRelease: + jogBits = 0; + handled = true; + break; + case vchrJogPushRepeat: + jogBits ^= keyBitHard1; + handled = true; + break; + case vchrJogBack: + event->data.keyDown.chr = 'P'; + break; + case /*vchrFind*/ 0x02F5: // CTRL-C + kbdCount = 0; + event->data.keyDown.chr = 3; + break; + case /*vchrCalc*/ 0x02F6: // ESC + kbdCount = 0; + event->data.keyDown.chr = 27; + break; + case chrLeftArrow: + case /*vchrHard2*/ 0x02F2: + event->data.keyDown.chr = 136; + break; + case chrRightArrow: + case /*vchrHard3*/ 0x02F3: + event->data.keyDown.chr = 149; + break; + case chrUpArrow: + case vchrPageUp: + event->data.keyDown.chr = 139; + break; + case chrDownArrow: + case vchrPageDown: + event->data.keyDown.chr = 138; + break; + case 10: // RETURN + event->data.keyDown.chr = 13; + break; + } + if (!handled) + Apple2PutKey(event->data.keyDown.chr); + handled = true; + break; + case frmOpenEvent: + frmApple2 = FrmGetActiveForm(); + if (grMode > GRMODE_COLOR) + { + /* + * Create gadgets for disk drive images. + */ + FrmNewGadget(&frmApple2, gadgetDrive1, 1, 125, 78, 34); + FrmNewGadget(&frmApple2, gadgetDrive2, 81, 125, 78, 34); + FrmSetGadgetHandler(frmApple2, FrmGetObjectIndex(frmApple2, gadgetDrive1), DriveHandleEvent); + FrmSetGadgetHandler(frmApple2, FrmGetObjectIndex(frmApple2, gadgetDrive2), DriveHandleEvent); + } + FrmDrawForm(frmApple2); + mountDisk(1, prefs.currentDsk[0][0] ? prefs.currentDsk[0] : NULL, prefs.writeEnable[0]); + positionDisk(1, prefs.currentTrack[0], prefs.currentPos[0]); + mountDisk(2, prefs.currentDsk[1][0] ? prefs.currentDsk[1] : NULL, prefs.writeEnable[1]); + positionDisk(2, prefs.currentTrack[1], prefs.currentPos[1]); + setCurrentDisk(prefs.currentDrive ? prefs.currentDrive : 1); + toggleMotor(prefs.currentMotor); + pause = false; + handled = true; + break; + case frmCloseEvent: + if (grMode > GRMODE_COLOR) + { + /* + * Remove gadgets for disk drive images. + */ + FrmRemoveObject(&frmApple2, FrmGetObjectIndex(frmApple2, gadgetDrive2)); + FrmRemoveObject(&frmApple2, FrmGetObjectIndex(frmApple2, gadgetDrive1)); + } + break; + case menuEvent: + handled = Apple2MenuHandleEvent(event->data.menu.itemID); + break; + case menuOpenEvent: + Apple2MenuSetItems(); + break; + } + return (handled); +} +/* + * Form UI elements helper routines. + */ +static void *GetObjectPtr(UInt16 objectID) +{ + FormType *form = FrmGetActiveForm(); + return (FrmGetObjectPtr(form, FrmGetObjectIndex(form, objectID))); +} +static void FieldSetValue(FieldType *field, UInt16 value) +{ + Char *mem; + MemHandle hMem = FldGetTextHandle(field); + FldSetTextHandle(field, NULL); + if (hMem) + MemHandleFree(hMem); + hMem = MemHandleNew(8); + mem = MemHandleLock(hMem); + StrPrintF(mem, "%d", value); + MemHandleUnlock(hMem); + FldSetTextHandle(field, hMem); +} +static void FieldSpin(FieldType *field, Int16 spin, Int16 min, Int16 max) +{ + MemHandle hMem; + Char *mem; + Int16 tmp; + + hMem = FldGetTextHandle(field); + FldSetTextHandle(field, NULL); + mem = MemHandleLock(hMem); + tmp = StrAToI(mem); + if (spin > 0) + { + if ((Int32)(tmp + spin) > (Int32)max) + tmp = max; + else + tmp += spin; + } + else + { + if ((Int32)(tmp + spin) < (Int32)min) + tmp = min; + else + tmp += spin; + } + StrPrintF(mem, "%d", tmp); + MemHandleUnlock(hMem); + FldSetTextHandle(field, hMem); + FldDrawField(field); +} +/* + * Load disk image. + */ +static Boolean LoadDiskHandleEvent(EventType *event) +{ + static Int16 numDsks; + static Char **nameDsks; + Int16 i, cardNo, otherDiskDrive; + UInt32 dbType; + DmSearchStateType searchState; + LocalID dbID; + Char name[33]; + Boolean first, handled = false; + switch (event->eType) + { + case frmOpenEvent: + if (jogAstMaskP) + *jogAstMaskP = jogAstOldMask; + /* + * Scan databases for disk images. + */ + otherDiskDrive = (LoadDiskDrive - 1) ^ 1; + first = true; + numDsks = 1; + while (!DmGetNextDatabaseByTypeCreator(first, &searchState, NULL, 'Apl2', false, &cardNo, &dbID)) + { + first = false; + DmDatabaseInfo(cardNo, dbID, name, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &dbType, NULL); + if (dbType == 'RDSK' || dbType == 'DDSK') + if (StrCompare(name, prefs.currentDsk[otherDiskDrive])) + numDsks++; + } + first = true; + nameDsks = MemPtrNew(numDsks * sizeof(Char *)); + nameDsks[0] = MemPtrNew(8); + StrCopy(nameDsks[0], "(none)"); + numDsks = 1; + while (!DmGetNextDatabaseByTypeCreator(first, &searchState, NULL, 'Apl2', false, &cardNo, &dbID)) + { + first = false; + DmDatabaseInfo(cardNo, dbID, name, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &dbType, NULL); + if (dbType == 'RDSK' || dbType == 'DDSK') + { + if (StrCompare(name, prefs.currentDsk[otherDiskDrive])) + { + nameDsks[numDsks] = MemPtrNew(32); + StrCopy(nameDsks[numDsks], name); + numDsks++; + } + } + } + LstSetListChoices(GetObjectPtr(lstDsk), nameDsks, numDsks); + FrmSetTitle(FrmGetActiveForm(), LoadDiskDrive == 1 ? "Load Disk 1 Image" : "Load Disk 2 Image"); + FrmDrawForm(FrmGetActiveForm()); + handled = true; + break; + case ctlSelectEvent: + switch (event->data.ctlSelect.controlID) + { + case buttonOk: + if ((i = LstGetSelection(GetObjectPtr(lstDsk))) != 0) + StrCopy(prefs.currentDsk[LoadDiskDrive - 1], LstGetSelectionText(GetObjectPtr(lstDsk), i)); + else + prefs.currentDsk[LoadDiskDrive - 1][0] = '\0'; + MemSemaphoreReserve(true); + if (CtlGetValue(GetObjectPtr(checkReset))) + { + initMemory(); + initVideo(); + reset6502(AppleMemory, WriteFunction, ReadFunction); + } + prefs.writeEnable[LoadDiskDrive - 1] = CtlGetValue(GetObjectPtr(checkWriteEnable)); + MemSemaphoreRelease(true); + case buttonCancel: + while(numDsks) + MemPtrFree(nameDsks[--numDsks]); + MemPtrFree(nameDsks); + FrmReturnToForm(0); + if (event->data.ctlSelect.controlID == buttonOk) + { + MemSemaphoreReserve(true); + if (!mountDisk(LoadDiskDrive, prefs.currentDsk[LoadDiskDrive - 1][0] ? prefs.currentDsk[LoadDiskDrive - 1] : NULL, prefs.writeEnable[LoadDiskDrive - 1])) + prefs.currentDsk[LoadDiskDrive - 1][0] = '\0'; + MemSemaphoreRelease(true); + } + handled = true; + Apple2Pause(false); + if (jogAstMaskP) + *jogAstMaskP = jogAstMask; + break; + } + break; + } + return (handled); +} +/* + * Joystick settings. + */ +static Boolean JoystickSettingsHandleEvent(EventType *event) +{ + Boolean handled = false; + switch (event->eType) + { + case frmOpenEvent: + if (jogAstMaskP) + *jogAstMaskP = jogAstOldMask; + CtlSetValue(GetObjectPtr(checkAutoCenter), prefs.centerJoystickRate); + CtlSetValue(GetObjectPtr(checkSwapBttns), prefs.keyHard1); + FieldSetValue(GetObjectPtr(fieldMoveRate), prefs.moveJoystickRate); + FieldSetValue(GetObjectPtr(fieldYCenter), prefs.centerJoystickVertPos - 128); + FieldSetValue(GetObjectPtr(fieldXCenter), prefs.centerJoystickHorizPos - 128); + FrmDrawForm(FrmGetActiveForm()); + handled = true; + break; + case ctlRepeatEvent: + switch (event->data.ctlSelect.controlID) + { + case buttonIncRate: + case buttonDecRate: + FieldSpin(GetObjectPtr(fieldMoveRate), event->data.ctlSelect.controlID == buttonIncRate ? 5 : -5, 1, 128); + break; + case buttonIncYCenter: + case buttonDecYCenter: + FieldSpin(GetObjectPtr(fieldYCenter), event->data.ctlSelect.controlID == buttonIncYCenter ? 4 : -4, -120, 120); + break; + case buttonIncXCenter: + case buttonDecXCenter: + FieldSpin(GetObjectPtr(fieldXCenter), event->data.ctlSelect.controlID == buttonIncXCenter ? 4 : -4, -120, 120); + break; + } + break; + case ctlSelectEvent: + switch (event->data.ctlSelect.controlID) + { + case buttonOk: + prefs.centerJoystickRate = CtlGetValue(GetObjectPtr(checkAutoCenter)) ? 0x10 : 0x00; + prefs.keyHard1 = CtlGetValue(GetObjectPtr(checkSwapBttns)) ? 1 : 0; + prefs.keyHard4 = 1 - prefs.keyHard1; + prefs.moveJoystickRate = StrAToI(FldGetTextPtr(GetObjectPtr(fieldMoveRate))); + prefs.centerJoystickVertPos = 128 + StrAToI(FldGetTextPtr(GetObjectPtr(fieldYCenter))); + prefs.centerJoystickHorizPos = 128 + StrAToI(FldGetTextPtr(GetObjectPtr(fieldXCenter))); + case buttonCancel: + FrmReturnToForm(0); + handled = true; + Apple2Pause(false); + if (jogAstMaskP) + *jogAstMaskP = jogAstMask; + break; + } + break; + } + return (handled); +} + +/*****************************************************************************\ +* * +* Application start/stop/main routines * +* * +\*****************************************************************************/ + +static Boolean AppStart(void) +{ + UInt16 prefSize; + Err error; + SonySysFtrSysInfoP sonySysFtrSysInfoP; + UInt32 version, depths, screen_width; + Boolean reset = false; + /* + * Get sound volume. + */ + AppleVolume = PrefGetPreference(prefGameSoundVolume); + A2Hz = 50; + refSnd = refPa1 = 0; + jogAstMaskP = NULL; + /* + * Check for audio and HiRes capability. + */ + WinScreenMode(winScreenModeGetSupportedDepths, NULL, NULL, &depths, NULL); + grMode = (depths & 0x80) ? GRMODE_COLOR : GRMODE_MONO; + if (!(error = FtrGet(sonySysFtrCreator, sonySysFtrNumSysInfoP, (UInt32*)&sonySysFtrSysInfoP))) + { + if (sonySysFtrSysInfoP->libr & sonySysFtrSysInfoLibrHR) + { + if ((error = SysLibFind(sonySysLibNameHR, &refHR))) + { + if (error == sysErrLibNotFound) + error = SysLibLoad('libr', sonySysFileCHRLib, &refHR); + } + grMode = GRMODE_SONYHR_COLOR; + } +#ifdef CLIE_SOUND + if (AppleVolume) + { + if (sonySysFtrSysInfoP->libr & sonySysFtrSysInfoLibrFm) + { + if ((error = SysLibFind(sonySysLibNameSound, &refSnd))) + { + if (error == sysErrLibNotFound) + error = SysLibLoad('libr', sonySysFileCSoundLib, &refSnd); + } + } + if ((error = SysLibFind(PA1Lib_NAME, &refPa1))) + error = SysLibLoad('libr', PA1Lib_ID, &refPa1); + if (!error) + { + if ((error = PA1LibOpen(refPa1))) + refPa1 = 0; + } + if (refPa1) + { + Boolean retval; + PA1L_midiOpen(refPa1, NULL, &hMidi, &retval); + SonySetVolume(refPa1, AppleVolume); + } + } +#endif + /* + * Mask off the JogAssist Handler. + */ + if (!FtrGet(sonySysFtrCreator, sonySysFtrNumJogAstMaskP, (UInt32*)&jogAstMaskP)) + { + jogAstMask[0] = 2; + jogAstMask[1] = 0x00FF; + jogAstOldMask = *jogAstMaskP; + *jogAstMaskP = jogAstMask; + } + A2Hz >>= 1; // Clie plays sound too fast + } + else + { + error = FtrGet(sysFtrCreator, sysFtrNumWinVersion, &version); + if (version >= 4) + { + error = WinScreenGetAttribute(winScreenWidth, &screen_width); + if (screen_width >= 320) + grMode = GRMODE_OS5HR_COLOR; + else + { + UInt16 density = 0; + do + { + error = WinGetSupportedDensity(&density); + if (!error) + { + if (density == kDensityDouble) + grMode = GRMODE_OS5HR_COLOR; + } + else + density = 0; + } while (density != 0); + } + } + } + /* + * Initialize globals. + */ + StrCopy(Title, "Appalm ]["); + jogBits = 0; + /* + * Look for existing emulator memory. Create if not found. + */ + MemSemaphoreReserve(true); + if (FtrGet('Apl2', 1, (UInt32 *)&AppleMemory) != 0) + { + FtrPtrNew('Apl2', 1, 65536, (void **)&AppleMemory); + reset = true; + } + if (FtrGet('Apl2', 2, (UInt32 *)&AuxMemory) != 0) + { + FtrPtrNew('Apl2', 2, 16384+2048, (void **)&AuxMemory); + reset = true; + } + MemSemaphoreRelease(true); + ReadFunction = (READBYTE *)MemPtrNew(2048); + MemSet(ReadFunction, 2048, 0); + WriteFunction = (WRITEBYTE *)&(ReadFunction[256]); + /* + * Get preferences. + */ + prefSize = sizeof(prefs); + if (!PrefGetAppPreferences('Apl2', 0, &prefs, &prefSize, true) && (prefs.version == PREFS_VERSION)) + { + /* + * Copy saved state into emulator. + */ + reset6502(AppleMemory, WriteFunction, ReadFunction); + state6502.LongRegs.ACC = prefs.state6502_ACC; + state6502.LongRegs.X = prefs.state6502_X; + state6502.LongRegs.Y = prefs.state6502_Y; + state6502.LongRegs.SP_CC = prefs.state6502_SP_CC; + state6502.LongRegs.PC = prefs.state6502_PC + (UInt32)AppleMemory; + status6502 = prefs.status6502; + memIOU = prefs.memIOU; + vidIOU = prefs.vidIOU; + MemSemaphoreReserve(true); + loadROM(); + setMemFuncs(); + MemSemaphoreRelease(true); + } + else + { + MemSet(&prefs, prefSize, 0); + /* + * Set default prefs. + */ + prefs.centerJoystickRate = 0; + prefs.moveJoystickRate = 16; + prefs.centerJoystickHorizPos = 0x80; + prefs.centerJoystickVertPos = 0x80; + prefs.keyHardMask = KEY_MASK_ALL; + prefs.keyHard1 = 0; + prefs.keyHard4 = 1; + prefs.refreshRate = 2; + prefs.enable80Col = true; + prefs.muteSound = false; + prefs.capsLock = false; + prefs.ignoreBadOps = false; + reset = true; + } + if (reset) + { + MemSemaphoreReserve(true); + initMemory(); + reset6502(AppleMemory, WriteFunction, ReadFunction); + MemSemaphoreRelease(true); + } + kbdIOU = + spkrIOU = + btnIOU[0] = + btnIOU[1] = + btnIOU[2] = + pdlIOU[0] = + pdlIOU[1] = 0; + pdlResetIOU[0] = + pdlResetIOU[1] = 0x80; + kbdHead = + kbdCount = 0; + /* + * Set up video. + */ + GrSetMode(); + initVideo(); + /* + * Check for muted audio. + */ + if (prefs.muteSound) + AppleVolume = 0; + /* + * Mask off the hard key events. + */ + KeySetMask(prefs.keyHardMask); + /* + * Init the instruction count and increment. + */ + AppleInstrCount = 0; + AppleInstrInc = prefs.refreshRate ? prefs.refreshRate * 5000 : 5000; + /* + * Don't start running yet. + */ + pause = true; + /* + * Goto main form. + */ + FrmGotoForm(Apple2Form); + return (true); +} +static void AppStop(void) +{ + /* + * Make sure default graphics mode is set. + */ + GrSetDefaultMode(); +#ifdef CLIE_SOUND + if (refPa1) + { + UInt16 usecount; + Boolean retval; + + SonySetVolume(refPa1, 0); + PA1L_midiClose(refPa1, hMidi, &retval); + PA1LibClose(refPa1, &usecount); + if (usecount == 0) + SysLibRemove(refPa1); + } +#endif + /* + * Clear Jog Assist mask. + */ + if (jogAstMaskP) + *jogAstMaskP = jogAstOldMask; + /* + * Save preferences. + */ + prefs.version = PREFS_VERSION; + prefs.state6502_ACC = state6502.LongRegs.ACC; + prefs.state6502_X = state6502.LongRegs.X; + prefs.state6502_Y = state6502.LongRegs.Y; + prefs.state6502_SP_CC = state6502.LongRegs.SP_CC; + prefs.state6502_PC = state6502.LongRegs.PC - state6502.LongRegs.MEMBASE; + prefs.status6502 = status6502; + prefs.memIOU = memIOU; + prefs.vidIOU = vidIOU; + unloadROM(); + MemSemaphoreReserve(true); + queryDisk(1, &prefs.currentTrack[0], &prefs.currentPos[0]); + queryDisk(2, &prefs.currentTrack[1], &prefs.currentPos[1]); + prefs.currentMotor = getCurrentDrive() & 0x80 ? true : false; + prefs.currentDrive = getCurrentDrive() & 0x0F; + umountDisk(1); + umountDisk(2); + MemSemaphoreRelease(true); + PrefSetAppPreferences('Apl2', 0, 0, &prefs, sizeof(prefs), true); + /* + * Release any resources. + */ + MemPtrFree(ReadFunction); + /* + * Unmask off the hard key events. + */ + KeySetMask(keyBitsAll); +} +static Boolean AppProcessEvent(EventType *event) +{ + UInt16 error; + FormType *frm; + + /* + * Hijack the hard keys. + */ + if ((event->eType == keyDownEvent) && (event->data.keyDown.modifiers & commandKeyMask)) + { + /* + * Remap the silk-screen keys. + */ + if ((event->data.keyDown.chr >= vchrFind) && (event->data.keyDown.chr <= vchrCalc)) + { + event->data.keyDown.modifiers &= ~commandKeyMask; + event->data.keyDown.chr = event->data.keyDown.chr - vchrFind + 0x02F5; + } + /* + * Remap the hard keys. + */ + else if ((event->data.keyDown.chr >= vchrHard1) && (event->data.keyDown.chr <= vchrHard4)) + { + event->data.keyDown.modifiers &= ~commandKeyMask; + event->data.keyDown.chr = event->data.keyDown.chr - vchrHard1 + 0x02F1; + } + /* + * Capture menu bar open/close. + */ + else if ((event->data.keyDown.chr == vchrMenu) && (FrmGetFormId(FrmGetActiveForm()) == Apple2Form)) + { + Apple2Pause(true); + } + } + if (!SysHandleEvent(event) && !MenuHandleEvent(0, event, &error)) + { + /* + * Application specific event. + */ + if (event->eType == frmLoadEvent) + { + /* + * Load the form resource specified in the event then activate the form. + */ + frm = FrmInitForm(event->data.frmLoad.formID); + FrmSetActiveForm(frm); + /* + * Set the event handler for the form. The handler of the currently + * active form is called by FrmDispatchEvent each time it receives an event. + */ + switch (event->data.frmLoad.formID) + { + case Apple2Form: + FrmSetEventHandler(frm, Apple2HandleEvent); + break; + case LoadDiskForm: + FrmSetEventHandler(frm, LoadDiskHandleEvent); + break; + case JoystickSettingsForm: + FrmSetEventHandler(frm, JoystickSettingsHandleEvent); + break; + } + } + else + /* + * Pass it on to the form handler. + */ + FrmDispatchEvent(event); + } + return (event->eType != appStopEvent); +} +/* + * Main. + */ +UInt32 PilotMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) +{ + UInt16 error, offTimer; + EventType event; + Boolean running; + UInt32 hardKeys, prevHardKeys; + + if ((error = RomVersionCompatible(ROM_VERSION_3_5, launchFlags))) + return(error); + if (cmd == sysAppLaunchCmdNormalLaunch) + { + if (AppStart()) + { + /* + * Main event loop. + */ + prevHardKeys = 0; + offTimer = 500; + running = true; + while (running) + { + EvtGetEvent(&event, 0); + if (event.eType == nilEvent && !pause) + { + Apple2Run(AppleInstrInc); + AppleInstrCount += AppleInstrInc; + hardKeys = KeyCurrentState() | jogBits; + btnIOU[prefs.keyHard1] = hardKeys & keyBitHard1; + btnIOU[prefs.keyHard4] = hardKeys & keyBitHard4; + if (prefs.keyHardMask == KEY_MASK_ALL) + { + if (hardKeys & (keyBitPageUp | keyBitPageDown)) + { + if ((hardKeys & (keyBitPageUp | keyBitPageDown)) == (keyBitPageUp | keyBitPageDown)) + { + pdlResetIOU[1] = prefs.centerJoystickHorizPos; + } + else if (hardKeys & keyBitPageUp) + { + pdlResetIOU[1] -= prefs.moveJoystickRate; + if (pdlResetIOU[1] > 0xFF) + pdlResetIOU[1] = 0x00; + } + else + { + pdlResetIOU[1] += prefs.moveJoystickRate; + if (pdlResetIOU[1] > 0xFF) + pdlResetIOU[1] = 0xFF; + } + } + else if (prefs.centerJoystickRate) + { + pdlResetIOU[1] = prefs.centerJoystickVertPos; + } + if (hardKeys & (keyBitHard2 | keyBitHard3)) + { + if ((hardKeys & (keyBitHard2 | keyBitHard3)) == (keyBitHard2 | keyBitHard3)) + { + pdlResetIOU[0] = prefs.centerJoystickHorizPos; + } + else if (hardKeys & keyBitHard2) + { + pdlResetIOU[0] -= prefs.moveJoystickRate; + if (pdlResetIOU[0] > 0xFF) + pdlResetIOU[0] = 0x00; + } + else + { + pdlResetIOU[0] += prefs.moveJoystickRate; + if (pdlResetIOU[0] > 0xFF) + pdlResetIOU[0] = 0xFF; + } + } + else if (prefs.centerJoystickRate) + { + pdlResetIOU[0] = prefs.centerJoystickHorizPos; + } + } + if (hardKeys & (keyBitGameExt0 | keyBitGameExt1)) + { + if ((hardKeys & keyBitGameExt0) && !(prevHardKeys & keyBitGameExt0)) + Apple2PutKeyNonAlpha(136); // Left Arrow + if ((hardKeys & keyBitGameExt1) && !(prevHardKeys & keyBitGameExt1)) + Apple2PutKeyNonAlpha(149); // Right Arrow + } + prevHardKeys = hardKeys; + Apple2UpdateVideo(); + Apple2UpdateAudio(); + if (--offTimer == 0) + { + offTimer = 500; + EvtResetAutoOffTimer(); + } + } + else + { + offTimer = 500; + running = AppProcessEvent(&event); + } + } + AppStop(); + } + } + return(0); +} + diff --git a/src/appalm.rcp b/src/appalm.rcp new file mode 100755 index 0000000..5eb44c7 --- /dev/null +++ b/src/appalm.rcp @@ -0,0 +1,112 @@ +#include "appalm_rsc.h" + +VERSION ID 1000 "0.7.5" + +// +// Appalm resources. +// + +MENU ID 3000 +BEGIN + PULLDOWN "File" + BEGIN + MENUITEM "Load Disk 1 Image" ID menuLoadDisk1 "1" + MENUITEM "Load Disk 2 Image" ID menuLoadDisk2 "2" + MENUITEM "Appalm ][ Manager..." ID menuA2Manager + END + PULLDOWN "Input" + BEGIN + MENUITEM "ESC" ID menuESC "E" + MENUITEM "CTRL" ID menuCTRL "C" + MENUITEM "CAPS LOCK" ID menuCapsLock "L" + MENUITEM "CAPS UNLOCK" ID menuCapsUnlock "L" + MENUITEM "Flush Keyboard Buffer" ID menuFlushKbdBuf "F" + MENUITEM "Disable Joystick" ID menuDisableJoystick "J" + MENUITEM "Enable Joystick" ID menuEnableJoystick "J" + MENUITEM "Joystick Settings" ID menuJoystickSettings + END + PULLDOWN "Output" + BEGIN + MENUITEM "Increase Refresh Rate" ID menuIncRefresh "+" + MENUITEM "Decrease Refresh Rate" ID menuDecRefresh "-" + MENUITEM "Disable 80 Column Text" ID menuDisable80Col + MENUITEM "Enable 80 Column Text" ID menuEnable80Col + MENUITEM "Mute Sound" ID menuMuteSound "S" + MENUITEM "Unmute Sound" ID menuUnmuteSound "S" + END + PULLDOWN "Options" + BEGIN + MENUITEM "Pause" ID menuPause + MENUITEM "Unpause" ID menuUnpause + MENUITEM "Reset" ID menuReset "R" + MENUITEM "Ignore Bad Ops" ID menuIgnoreBadOps + MENUITEM "About" ID menuAbout + END +END + +FORM ID LoadDiskForm AT (15 15 130 140) +MODAL +BEGIN + TITLE "Load Disk" + LIST "" ID lstDsk AT (10 22 110 68) + CHECKBOX "Write Enable Disk" ID checkWriteEnable AT (10 93 AUTO AUTO) FONT 1 + CHECKBOX "Reset After Load" ID checkReset AT (10 105 AUTO AUTO) FONT 1 + BUTTON "OK" ID buttonOk AT (10 120 AUTO AUTO) + BUTTON "Cancel" ID buttonCancel AT (PREVRIGHT+10 PREVTOP AUTO AUTO) +END + +FORM ID JoystickSettingsForm AT (20 20 120 120) +MODAL +BEGIN + TITLE "Joystick Settings" + CHECKBOX "Auto Center" ID checkAutoCenter AT (15 15 AUTO AUTO) FONT 1 + CHECKBOX "Swap Buttons" ID checkSwapBttns AT (15 30 AUTO AUTO) FONT 1 + REPEATBUTTON "\001" ID buttonIncRate AT (5 45 13 8) NOFRAME FONT 5 + REPEATBUTTON "\002" ID buttonDecRate AT (PREVLEFT PREVBOTTOM 13 8) NOFRAME FONT 5 + FIELD ID fieldMoveRate AT (PREVLEFT+15 PREVBOTTOM-14 20 11) LEFTALIGN EDITABLE UNDERLINED SINGLELINE MAXCHARS 5 NUMERIC + LABEL "Move Rate" AUTOID AT (PREVLEFT+20 PREVTOP) FONT 1 + REPEATBUTTON "\001" ID buttonIncYCenter AT (5 PREVBOTTOM + 5 13 8) NOFRAME FONT 5 + REPEATBUTTON "\002" ID buttonDecYCenter AT (PREVLEFT PREVBOTTOM 13 8) NOFRAME FONT 5 + FIELD ID fieldYCenter AT (PREVLEFT+15 PREVBOTTOM-14 20 11) LEFTALIGN EDITABLE UNDERLINED SINGLELINE MAXCHARS 5 NUMERIC + LABEL "Y Axis Center" AUTOID AT (PREVLEFT+20 PREVTOP) FONT 1 + REPEATBUTTON "\001" ID buttonIncXCenter AT (5 PREVBOTTOM + 5 13 8) NOFRAME FONT 5 + REPEATBUTTON "\002" ID buttonDecXCenter AT (PREVLEFT PREVBOTTOM 13 8) NOFRAME FONT 5 + FIELD ID fieldXCenter AT (PREVLEFT+15 PREVBOTTOM-14 20 11) LEFTALIGN EDITABLE UNDERLINED SINGLELINE MAXCHARS 5 NUMERIC + LABEL "X Axis Center" AUTOID AT (PREVLEFT+20 PREVTOP) FONT 1 + BUTTON "OK" ID buttonOk AT (10 105 AUTO AUTO) + BUTTON "Cancel" ID buttonCancel AT (PREVRIGHT+10 PREVTOP AUTO AUTO) +END + +FORM ID Apple2Form AT (0 0 160 160) +MENUID 3000 +BEGIN + TITLE "Appalm ][" +END + +ALERT ID RomIncompatibleAlert +ERROR +BEGIN + TITLE "System Incompatible" + MESSAGE "System Version 3.5 or greater is required to run this application." + BUTTONS "OK" +END + +ALERT ID MessageBox +INFORMATION +BEGIN + TITLE "Message" + MESSAGE "^1" + BUTTONS "OK" +END + +ALERT ID AboutBox +INFORMATION +BEGIN + TITLE "About" + MESSAGE "Appalm ][ v 0.7.5\npalmapple.sf.net" + BUTTONS "OK" +END + +ICONFAMILY 1000 "icons/ApPalm_32x22_B&W.bmp" "icons/ApPalm_32x22_B&W.bmp" "icons/ApPalm_32x22_4grey.bmp" "icons/ApPalm_32x22_256.bmp" TRANSPARENT 255 0 255 + +SMALLICONFAMILY 1001 "icons/ApPalm_15x9_B&W.bmp" "icons/ApPalm_15x9_B&W.bmp" "icons/ApPalm_15x9_4grey.bmp" "icons/ApPalm_15x9_256.bmp" TRANSPARENT 255 0 255 diff --git a/src/appalm_rsc.h b/src/appalm_rsc.h new file mode 100755 index 0000000..e768fcb --- /dev/null +++ b/src/appalm_rsc.h @@ -0,0 +1,67 @@ +// Resource: tFRM 1000 +#define Apple2Form 1000 +#define LoadDiskForm 1100 +#define JoystickSettingsForm 1200 +// Resource: Talt 2300 +#define RomIncompatibleAlert 2300 +#define RomIncompatibleOK 0 + +// Resource: Talt 2500 +#define AboutBox 2500 + +// Resource: Talt 2600 +#define MessageBox 2600 +#define MesageOK 0 + +// MenuIDs +#define menuLoadDisk1 3011 +#define menuLoadDisk2 3012 +#define menuA2Manager 3013 +#define menuESC 3020 +#define menuCTRL 3021 +#define menuCapsLock 3022 +#define menuCapsUnlock 3023 +#define menuFlushKbdBuf 3024 +#define menuDisableJoystick 3025 +#define menuEnableJoystick 3026 +#define menuJoystickSettings 3027 +#define menuIncRefresh 3030 +#define menuDecRefresh 3031 +#define menuDisable80Col 3032 +#define menuEnable80Col 3033 +#define menuMuteSound 3034 +#define menuUnmuteSound 3035 +#define menuPause 3040 +#define menuUnpause 3041 +#define menuReset 3042 +#define menuIgnoreBadOps 3050 +#define menuAbout 3043 + +// Joystick UI IDs +#define checkAutoCenter 4000 +#define checkSwapBttns 4001 +#define buttonIncRate 4002 +#define buttonDecRate 4003 +#define fieldMoveRate 4004 +#define buttonIncYCenter 4005 +#define buttonDecYCenter 4006 +#define fieldYCenter 4007 +#define buttonIncXCenter 4008 +#define buttonDecXCenter 4009 +#define fieldXCenter 4010 + +// +// ButtonIDs +#define buttonOk 3100 +#define buttonCancel 3101 + +// LoadDisk UI IDs +#define lstDsk 3200 +#define checkWriteEnable 3201 +#define checkReset 3202 + +// Drive gadgets +#define gadgetDrive1 1001 +#define gadgetDrive2 1002 + + diff --git a/src/fonts4x6.c b/src/fonts4x6.c new file mode 100755 index 0000000..55a813e --- /dev/null +++ b/src/fonts4x6.c @@ -0,0 +1,137 @@ +/* + * fonts.c + */ + +/* + * apple fonts bitmap files + */ + +#include "fonts4x6/char00.bmp" +#include "fonts4x6/char01.bmp" +#include "fonts4x6/char02.bmp" +#include "fonts4x6/char03.bmp" +#include "fonts4x6/char04.bmp" +#include "fonts4x6/char05.bmp" +#include "fonts4x6/char06.bmp" +#include "fonts4x6/char07.bmp" +#include "fonts4x6/char08.bmp" +#include "fonts4x6/char09.bmp" +#include "fonts4x6/char0a.bmp" +#include "fonts4x6/char0b.bmp" +#include "fonts4x6/char0c.bmp" +#include "fonts4x6/char0d.bmp" +#include "fonts4x6/char0e.bmp" +#include "fonts4x6/char0f.bmp" +#include "fonts4x6/char10.bmp" +#include "fonts4x6/char11.bmp" +#include "fonts4x6/char12.bmp" +#include "fonts4x6/char13.bmp" +#include "fonts4x6/char14.bmp" +#include "fonts4x6/char15.bmp" +#include "fonts4x6/char16.bmp" +#include "fonts4x6/char17.bmp" +#include "fonts4x6/char18.bmp" +#include "fonts4x6/char19.bmp" +#include "fonts4x6/char1a.bmp" +#include "fonts4x6/char1b.bmp" +#include "fonts4x6/char1c.bmp" +#include "fonts4x6/char1d.bmp" +#include "fonts4x6/char1e.bmp" +#include "fonts4x6/char1f.bmp" +#include "fonts4x6/char20.bmp" +#include "fonts4x6/char21.bmp" +#include "fonts4x6/char22.bmp" +#include "fonts4x6/char23.bmp" +#include "fonts4x6/char24.bmp" +#include "fonts4x6/char25.bmp" +#include "fonts4x6/char26.bmp" +#include "fonts4x6/char27.bmp" +#include "fonts4x6/char28.bmp" +#include "fonts4x6/char29.bmp" +#include "fonts4x6/char2a.bmp" +#include "fonts4x6/char2b.bmp" +#include "fonts4x6/char2c.bmp" +#include "fonts4x6/char2d.bmp" +#include "fonts4x6/char2e.bmp" +#include "fonts4x6/char2f.bmp" +#include "fonts4x6/char30.bmp" +#include "fonts4x6/char31.bmp" +#include "fonts4x6/char32.bmp" +#include "fonts4x6/char33.bmp" +#include "fonts4x6/char34.bmp" +#include "fonts4x6/char35.bmp" +#include "fonts4x6/char36.bmp" +#include "fonts4x6/char37.bmp" +#include "fonts4x6/char38.bmp" +#include "fonts4x6/char39.bmp" +#include "fonts4x6/char3a.bmp" +#include "fonts4x6/char3b.bmp" +#include "fonts4x6/char3c.bmp" +#include "fonts4x6/char3d.bmp" +#include "fonts4x6/char3e.bmp" +#include "fonts4x6/char3f.bmp" +#include "fonts4x6/char40.bmp" +#include "fonts4x6/char41.bmp" +#include "fonts4x6/char42.bmp" +#include "fonts4x6/char43.bmp" +#include "fonts4x6/char44.bmp" +#include "fonts4x6/char45.bmp" +#include "fonts4x6/char46.bmp" +#include "fonts4x6/char47.bmp" +#include "fonts4x6/char48.bmp" +#include "fonts4x6/char49.bmp" +#include "fonts4x6/char4a.bmp" +#include "fonts4x6/char4b.bmp" +#include "fonts4x6/char4c.bmp" +#include "fonts4x6/char4d.bmp" +#include "fonts4x6/char4e.bmp" +#include "fonts4x6/char4f.bmp" +#include "fonts4x6/char50.bmp" +#include "fonts4x6/char51.bmp" +#include "fonts4x6/char52.bmp" +#include "fonts4x6/char53.bmp" +#include "fonts4x6/char54.bmp" +#include "fonts4x6/char55.bmp" +#include "fonts4x6/char56.bmp" +#include "fonts4x6/char57.bmp" +#include "fonts4x6/char58.bmp" +#include "fonts4x6/char59.bmp" +#include "fonts4x6/char5a.bmp" +#include "fonts4x6/char5b.bmp" +#include "fonts4x6/char5c.bmp" +#include "fonts4x6/char5d.bmp" +#include "fonts4x6/char5e.bmp" +#include "fonts4x6/char5f.bmp" + +/* + * bitmap index array + */ + +#define MAX_CHAR_BITMAP 0x60 + +char *AppleFontBitmap4x6[MAX_CHAR_BITMAP] = { + char00_bits, char01_bits, char02_bits, char03_bits, + char04_bits, char05_bits, char06_bits, char07_bits, + char08_bits, char09_bits, char0a_bits, char0b_bits, + char0c_bits, char0d_bits, char0e_bits, char0f_bits, + char10_bits, char11_bits, char12_bits, char13_bits, + char14_bits, char15_bits, char16_bits, char17_bits, + char18_bits, char19_bits, char1a_bits, char1b_bits, + char1c_bits, char1d_bits, char1e_bits, char1f_bits, + char20_bits, char21_bits, char22_bits, char23_bits, + char24_bits, char25_bits, char26_bits, char27_bits, + char28_bits, char29_bits, char2a_bits, char2b_bits, + char2c_bits, char2d_bits, char2e_bits, char2f_bits, + char30_bits, char31_bits, char32_bits, char33_bits, + char34_bits, char35_bits, char36_bits, char37_bits, + char38_bits, char39_bits, char3a_bits, char3b_bits, + char3c_bits, char3d_bits, char3e_bits, char3f_bits, + char40_bits, char41_bits, char42_bits, char43_bits, + char44_bits, char45_bits, char46_bits, char47_bits, + char48_bits, char49_bits, char4a_bits, char4b_bits, + char4c_bits, char4d_bits, char4e_bits, char4f_bits, + char50_bits, char51_bits, char52_bits, char53_bits, + char54_bits, char55_bits, char56_bits, char57_bits, + char58_bits, char59_bits, char5a_bits, char5b_bits, + char5c_bits, char5d_bits, char5e_bits, char5f_bits, +}; diff --git a/src/fonts4x6/CVS/Entries b/src/fonts4x6/CVS/Entries new file mode 100644 index 0000000..86f85be --- /dev/null +++ b/src/fonts4x6/CVS/Entries @@ -0,0 +1,97 @@ +/char00.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char01.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char02.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char03.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char04.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char05.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char06.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char07.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char08.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char09.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char0a.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char0b.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char0c.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char0d.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char0e.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char0f.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char10.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char11.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char12.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char13.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char14.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char15.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char16.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char17.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char18.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char19.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char1a.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char1b.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char1c.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char1d.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char1e.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char1f.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char20.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char21.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char22.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char23.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char24.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char25.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char26.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char27.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char28.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char29.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char2a.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char2b.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char2c.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char2d.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char2e.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char2f.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char30.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char31.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char32.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char33.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char34.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char35.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char36.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char37.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char38.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char39.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char3a.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char3b.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char3c.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char3d.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char3e.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char3f.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char40.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char41.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char42.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char43.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char44.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char45.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char46.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char47.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char48.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char49.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char4a.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char4b.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char4c.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char4d.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char4e.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char4f.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char50.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char51.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char52.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char53.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char54.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char55.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char56.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char57.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char58.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char59.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char5a.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char5b.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char5c.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char5d.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char5e.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char5f.bmp/1.1/Tue Jun 17 04:40:38 2003// +D diff --git a/src/fonts4x6/CVS/Repository b/src/fonts4x6/CVS/Repository new file mode 100644 index 0000000..2380f25 --- /dev/null +++ b/src/fonts4x6/CVS/Repository @@ -0,0 +1 @@ +palmapple/src/fonts4x6 diff --git a/src/fonts4x6/CVS/Root b/src/fonts4x6/CVS/Root new file mode 100644 index 0000000..bdb6620 --- /dev/null +++ b/src/fonts4x6/CVS/Root @@ -0,0 +1 @@ +:ext:dschmenk@cvs.sourceforge.net:/cvsroot/palmapple diff --git a/src/fonts4x6/char00.bmp b/src/fonts4x6/char00.bmp new file mode 100755 index 0000000..4572dcb --- /dev/null +++ b/src/fonts4x6/char00.bmp @@ -0,0 +1,3 @@ +#define char00_width 4 +#define char00_height 6 +static char char00_bits[] = {0x06, 0x0e, 0x0e, 0x0c, 0x06, 0x00}; diff --git a/src/fonts4x6/char01.bmp b/src/fonts4x6/char01.bmp new file mode 100755 index 0000000..eade0ba --- /dev/null +++ b/src/fonts4x6/char01.bmp @@ -0,0 +1,3 @@ +#define char01_width 4 +#define char01_height 6 +static char char01_bits[] = {0x04, 0x0e, 0x0a, 0x0e, 0x0a, 0x00}; diff --git a/src/fonts4x6/char02.bmp b/src/fonts4x6/char02.bmp new file mode 100755 index 0000000..060b488 --- /dev/null +++ b/src/fonts4x6/char02.bmp @@ -0,0 +1,3 @@ +#define char02_width 4 +#define char02_height 6 +static char char02_bits[] = {0x0c, 0x0a, 0x0c, 0x0a, 0x0c, 0x00}; diff --git a/src/fonts4x6/char03.bmp b/src/fonts4x6/char03.bmp new file mode 100755 index 0000000..017c7e7 --- /dev/null +++ b/src/fonts4x6/char03.bmp @@ -0,0 +1,3 @@ +#define char03_width 4 +#define char03_height 6 +static char char03_bits[] = {0x04, 0x0a, 0x08, 0x0a, 0x04, 0x00}; diff --git a/src/fonts4x6/char04.bmp b/src/fonts4x6/char04.bmp new file mode 100755 index 0000000..a77f44c --- /dev/null +++ b/src/fonts4x6/char04.bmp @@ -0,0 +1,3 @@ +#define char04_width 4 +#define char04_height 6 +static char char04_bits[] = {0x0c, 0x0a, 0x0a, 0x0a, 0x0c, 0x00}; diff --git a/src/fonts4x6/char05.bmp b/src/fonts4x6/char05.bmp new file mode 100755 index 0000000..3e4062c --- /dev/null +++ b/src/fonts4x6/char05.bmp @@ -0,0 +1,3 @@ +#define char05_width 4 +#define char05_height 6 +static char char05_bits[] = {0x0e, 0x08, 0x0c, 0x08, 0x0e, 0x00}; diff --git a/src/fonts4x6/char06.bmp b/src/fonts4x6/char06.bmp new file mode 100755 index 0000000..91eddca --- /dev/null +++ b/src/fonts4x6/char06.bmp @@ -0,0 +1,3 @@ +#define char06_width 4 +#define char06_height 6 +static char char06_bits[] = {0x0e, 0x08, 0x0c, 0x08, 0x08, 0x00}; diff --git a/src/fonts4x6/char07.bmp b/src/fonts4x6/char07.bmp new file mode 100755 index 0000000..1fec5e6 --- /dev/null +++ b/src/fonts4x6/char07.bmp @@ -0,0 +1,3 @@ +#define char07_width 4 +#define char07_height 6 +static char char07_bits[] = {0x06, 0x08, 0x08, 0x0e, 0x06, 0x00}; diff --git a/src/fonts4x6/char08.bmp b/src/fonts4x6/char08.bmp new file mode 100755 index 0000000..a198d28 --- /dev/null +++ b/src/fonts4x6/char08.bmp @@ -0,0 +1,3 @@ +#define char08_width 4 +#define char08_height 6 +static char char08_bits[] = {0x0a, 0x0a, 0x0e, 0x0a, 0x0a, 0x00}; diff --git a/src/fonts4x6/char09.bmp b/src/fonts4x6/char09.bmp new file mode 100755 index 0000000..dd68448 --- /dev/null +++ b/src/fonts4x6/char09.bmp @@ -0,0 +1,3 @@ +#define char09_width 4 +#define char09_height 6 +static char char09_bits[] = {0x0e, 0x04, 0x04, 0x04, 0x0e, 0x00}; diff --git a/src/fonts4x6/char0a.bmp b/src/fonts4x6/char0a.bmp new file mode 100755 index 0000000..4327d41 --- /dev/null +++ b/src/fonts4x6/char0a.bmp @@ -0,0 +1,3 @@ +#define char0a_width 4 +#define char0a_height 6 +static char char0a_bits[] = {0x02, 0x02, 0x02, 0x0a, 0x04, 0x00}; diff --git a/src/fonts4x6/char0b.bmp b/src/fonts4x6/char0b.bmp new file mode 100755 index 0000000..d854f0e --- /dev/null +++ b/src/fonts4x6/char0b.bmp @@ -0,0 +1,3 @@ +#define char0b_width 4 +#define char0b_height 6 +static char char0b_bits[] = {0x0a, 0x0c, 0x0c, 0x0c, 0x0a, 0x00}; diff --git a/src/fonts4x6/char0c.bmp b/src/fonts4x6/char0c.bmp new file mode 100755 index 0000000..b32616b --- /dev/null +++ b/src/fonts4x6/char0c.bmp @@ -0,0 +1,3 @@ +#define char0c_width 4 +#define char0c_height 6 +static char char0c_bits[] = {0x08, 0x08, 0x08, 0x08, 0x0e, 0x00}; diff --git a/src/fonts4x6/char0d.bmp b/src/fonts4x6/char0d.bmp new file mode 100755 index 0000000..3cc1714 --- /dev/null +++ b/src/fonts4x6/char0d.bmp @@ -0,0 +1,3 @@ +#define char0d_width 4 +#define char0d_height 6 +static char char0d_bits[] = {0x0a, 0x0e, 0x0e, 0x0a, 0x0a, 0x00}; diff --git a/src/fonts4x6/char0e.bmp b/src/fonts4x6/char0e.bmp new file mode 100755 index 0000000..ba68542 --- /dev/null +++ b/src/fonts4x6/char0e.bmp @@ -0,0 +1,3 @@ +#define char0e_width 4 +#define char0e_height 6 +static char char0e_bits[] = {0x0a, 0x0e, 0x0e, 0x0e, 0x0a, 0x00}; diff --git a/src/fonts4x6/char0f.bmp b/src/fonts4x6/char0f.bmp new file mode 100755 index 0000000..585c56d --- /dev/null +++ b/src/fonts4x6/char0f.bmp @@ -0,0 +1,3 @@ +#define char0f_width 4 +#define char0f_height 6 +static char char0f_bits[] = {0x04, 0x0a, 0x0a, 0x0a, 0x04, 0x00}; diff --git a/src/fonts4x6/char10.bmp b/src/fonts4x6/char10.bmp new file mode 100755 index 0000000..62ca00f --- /dev/null +++ b/src/fonts4x6/char10.bmp @@ -0,0 +1,3 @@ +#define char10_width 4 +#define char10_height 6 +static char char10_bits[] = {0x0c, 0x0a, 0x0c, 0x08, 0x08, 0x00}; diff --git a/src/fonts4x6/char11.bmp b/src/fonts4x6/char11.bmp new file mode 100755 index 0000000..e1c2c3b --- /dev/null +++ b/src/fonts4x6/char11.bmp @@ -0,0 +1,3 @@ +#define char11_width 4 +#define char11_height 6 +static char char11_bits[] = {0x04, 0x0a, 0x0a, 0x0e, 0x06, 0x00}; diff --git a/src/fonts4x6/char12.bmp b/src/fonts4x6/char12.bmp new file mode 100755 index 0000000..ea7e059 --- /dev/null +++ b/src/fonts4x6/char12.bmp @@ -0,0 +1,3 @@ +#define char12_width 4 +#define char12_height 6 +static char char12_bits[] = {0x0c, 0x0a, 0x0c, 0x0c, 0x0a, 0x00}; diff --git a/src/fonts4x6/char13.bmp b/src/fonts4x6/char13.bmp new file mode 100755 index 0000000..d152ee3 --- /dev/null +++ b/src/fonts4x6/char13.bmp @@ -0,0 +1,3 @@ +#define char13_width 4 +#define char13_height 6 +static char char13_bits[] = {0x06, 0x08, 0x04, 0x02, 0x0c, 0x00}; diff --git a/src/fonts4x6/char14.bmp b/src/fonts4x6/char14.bmp new file mode 100755 index 0000000..a8db4d4 --- /dev/null +++ b/src/fonts4x6/char14.bmp @@ -0,0 +1,3 @@ +#define char14_width 4 +#define char14_height 6 +static char char14_bits[] = {0x0e, 0x04, 0x04, 0x04, 0x04, 0x00}; diff --git a/src/fonts4x6/char15.bmp b/src/fonts4x6/char15.bmp new file mode 100755 index 0000000..db9f148 --- /dev/null +++ b/src/fonts4x6/char15.bmp @@ -0,0 +1,3 @@ +#define char15_width 4 +#define char15_height 6 +static char char15_bits[] = {0x0a, 0x0a, 0x0a, 0x0a, 0x06, 0x00}; diff --git a/src/fonts4x6/char16.bmp b/src/fonts4x6/char16.bmp new file mode 100755 index 0000000..b80d100 --- /dev/null +++ b/src/fonts4x6/char16.bmp @@ -0,0 +1,3 @@ +#define char16_width 4 +#define char16_height 6 +static char char16_bits[] = {0x0a, 0x0a, 0x0a, 0x0e, 0x04, 0x00}; diff --git a/src/fonts4x6/char17.bmp b/src/fonts4x6/char17.bmp new file mode 100755 index 0000000..ac81190 --- /dev/null +++ b/src/fonts4x6/char17.bmp @@ -0,0 +1,3 @@ +#define char17_width 4 +#define char17_height 6 +static char char17_bits[] = {0x0a, 0x0a, 0x0e, 0x0e, 0x0a, 0x00}; diff --git a/src/fonts4x6/char18.bmp b/src/fonts4x6/char18.bmp new file mode 100755 index 0000000..e63afb1 --- /dev/null +++ b/src/fonts4x6/char18.bmp @@ -0,0 +1,3 @@ +#define char18_width 4 +#define char18_height 6 +static char char18_bits[] = {0x0a, 0x0e, 0x04, 0x0e, 0x0a, 0x00}; diff --git a/src/fonts4x6/char19.bmp b/src/fonts4x6/char19.bmp new file mode 100755 index 0000000..bc08db7 --- /dev/null +++ b/src/fonts4x6/char19.bmp @@ -0,0 +1,3 @@ +#define char19_width 4 +#define char19_height 6 +static char char19_bits[] = {0x0a, 0x0e, 0x04, 0x04, 0x04, 0x00}; diff --git a/src/fonts4x6/char1a.bmp b/src/fonts4x6/char1a.bmp new file mode 100755 index 0000000..f2d9f2d --- /dev/null +++ b/src/fonts4x6/char1a.bmp @@ -0,0 +1,3 @@ +#define char1a_width 4 +#define char1a_height 6 +static char char1a_bits[] = {0x0e, 0x06, 0x04, 0x0c, 0x0e, 0x00}; diff --git a/src/fonts4x6/char1b.bmp b/src/fonts4x6/char1b.bmp new file mode 100755 index 0000000..644d17c --- /dev/null +++ b/src/fonts4x6/char1b.bmp @@ -0,0 +1,3 @@ +#define char1b_width 4 +#define char1b_height 6 +static char char1b_bits[] = {0x0e, 0x0c, 0x0c, 0x0c, 0x0e, 0x00}; diff --git a/src/fonts4x6/char1c.bmp b/src/fonts4x6/char1c.bmp new file mode 100755 index 0000000..854e9ea --- /dev/null +++ b/src/fonts4x6/char1c.bmp @@ -0,0 +1,3 @@ +#define char1c_width 4 +#define char1c_height 6 +static char char1c_bits[] = {0x00, 0x0c, 0x04, 0x06, 0x00, 0x00}; diff --git a/src/fonts4x6/char1d.bmp b/src/fonts4x6/char1d.bmp new file mode 100755 index 0000000..1bf7dcc --- /dev/null +++ b/src/fonts4x6/char1d.bmp @@ -0,0 +1,3 @@ +#define char1d_width 4 +#define char1d_height 6 +static char char1d_bits[] = {0x0e, 0x06, 0x06, 0x06, 0x0e, 0x00}; diff --git a/src/fonts4x6/char1e.bmp b/src/fonts4x6/char1e.bmp new file mode 100755 index 0000000..abd098e --- /dev/null +++ b/src/fonts4x6/char1e.bmp @@ -0,0 +1,3 @@ +#define char1e_width 4 +#define char1e_height 6 +static char char1e_bits[] = {0x00, 0x04, 0x04, 0x0a, 0x00, 0x00}; diff --git a/src/fonts4x6/char1f.bmp b/src/fonts4x6/char1f.bmp new file mode 100755 index 0000000..8d49272 --- /dev/null +++ b/src/fonts4x6/char1f.bmp @@ -0,0 +1,3 @@ +#define char1f_width 4 +#define char1f_height 6 +static char char1f_bits[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x0e}; diff --git a/src/fonts4x6/char20.bmp b/src/fonts4x6/char20.bmp new file mode 100755 index 0000000..392d065 --- /dev/null +++ b/src/fonts4x6/char20.bmp @@ -0,0 +1,3 @@ +#define char20_width 4 +#define char20_height 6 +static char char20_bits[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/src/fonts4x6/char21.bmp b/src/fonts4x6/char21.bmp new file mode 100755 index 0000000..bee348c --- /dev/null +++ b/src/fonts4x6/char21.bmp @@ -0,0 +1,3 @@ +#define char21_width 4 +#define char21_height 6 +static char char21_bits[] = {0x04, 0x04, 0x04, 0x04, 0x04, 0x00}; diff --git a/src/fonts4x6/char22.bmp b/src/fonts4x6/char22.bmp new file mode 100755 index 0000000..214ebb9 --- /dev/null +++ b/src/fonts4x6/char22.bmp @@ -0,0 +1,3 @@ +#define char22_width 4 +#define char22_height 6 +static char char22_bits[] = {0x04, 0x04, 0x00, 0x00, 0x00, 0x00}; diff --git a/src/fonts4x6/char23.bmp b/src/fonts4x6/char23.bmp new file mode 100755 index 0000000..93696a4 --- /dev/null +++ b/src/fonts4x6/char23.bmp @@ -0,0 +1,3 @@ +#define char23_width 4 +#define char23_height 6 +static char char23_bits[] = {0x04, 0x0e, 0x04, 0x0e, 0x04, 0x00}; diff --git a/src/fonts4x6/char24.bmp b/src/fonts4x6/char24.bmp new file mode 100755 index 0000000..f36e8c2 --- /dev/null +++ b/src/fonts4x6/char24.bmp @@ -0,0 +1,3 @@ +#define char24_width 4 +#define char24_height 6 +static char char24_bits[] = {0x04, 0x0e, 0x04, 0x0e, 0x04, 0x00}; diff --git a/src/fonts4x6/char25.bmp b/src/fonts4x6/char25.bmp new file mode 100755 index 0000000..5969013 --- /dev/null +++ b/src/fonts4x6/char25.bmp @@ -0,0 +1,3 @@ +#define char25_width 4 +#define char25_height 6 +static char char25_bits[] = {0x0c, 0x0e, 0x04, 0x0e, 0x06, 0x00}; diff --git a/src/fonts4x6/char26.bmp b/src/fonts4x6/char26.bmp new file mode 100755 index 0000000..2869228 --- /dev/null +++ b/src/fonts4x6/char26.bmp @@ -0,0 +1,3 @@ +#define char26_width 4 +#define char26_height 6 +static char char26_bits[] = {0x04, 0x0c, 0x04, 0x0e, 0x06, 0x00}; diff --git a/src/fonts4x6/char27.bmp b/src/fonts4x6/char27.bmp new file mode 100755 index 0000000..1db70ca --- /dev/null +++ b/src/fonts4x6/char27.bmp @@ -0,0 +1,3 @@ +#define char27_width 4 +#define char27_height 6 +static char char27_bits[] = {0x04, 0x04, 0x00, 0x00, 0x00, 0x00}; diff --git a/src/fonts4x6/char28.bmp b/src/fonts4x6/char28.bmp new file mode 100755 index 0000000..0ce37a5 --- /dev/null +++ b/src/fonts4x6/char28.bmp @@ -0,0 +1,3 @@ +#define char28_width 4 +#define char28_height 6 +static char char28_bits[] = {0x04, 0x0c, 0x08, 0x0c, 0x04, 0x00}; diff --git a/src/fonts4x6/char29.bmp b/src/fonts4x6/char29.bmp new file mode 100755 index 0000000..25de697 --- /dev/null +++ b/src/fonts4x6/char29.bmp @@ -0,0 +1,3 @@ +#define char29_width 4 +#define char29_height 6 +static char char29_bits[] = {0x04, 0x06, 0x02, 0x06, 0x04, 0x00}; diff --git a/src/fonts4x6/char2a.bmp b/src/fonts4x6/char2a.bmp new file mode 100755 index 0000000..25a4d2a --- /dev/null +++ b/src/fonts4x6/char2a.bmp @@ -0,0 +1,3 @@ +#define char2a_width 4 +#define char2a_height 6 +static char char2a_bits[] = {0x04, 0x0e, 0x04, 0x0e, 0x04, 0x00}; diff --git a/src/fonts4x6/char2b.bmp b/src/fonts4x6/char2b.bmp new file mode 100755 index 0000000..c52094b --- /dev/null +++ b/src/fonts4x6/char2b.bmp @@ -0,0 +1,3 @@ +#define char2b_width 4 +#define char2b_height 6 +static char char2b_bits[] = {0x00, 0x04, 0x0e, 0x04, 0x00, 0x00}; diff --git a/src/fonts4x6/char2c.bmp b/src/fonts4x6/char2c.bmp new file mode 100755 index 0000000..3fab9ce --- /dev/null +++ b/src/fonts4x6/char2c.bmp @@ -0,0 +1,3 @@ +#define char2c_width 4 +#define char2c_height 6 +static char char2c_bits[] = {0x00, 0x00, 0x00, 0x04, 0x04, 0x00}; diff --git a/src/fonts4x6/char2d.bmp b/src/fonts4x6/char2d.bmp new file mode 100755 index 0000000..c6b9db6 --- /dev/null +++ b/src/fonts4x6/char2d.bmp @@ -0,0 +1,3 @@ +#define char2d_width 4 +#define char2d_height 6 +static char char2d_bits[] = {0x00, 0x00, 0x0e, 0x00, 0x00, 0x00}; diff --git a/src/fonts4x6/char2e.bmp b/src/fonts4x6/char2e.bmp new file mode 100755 index 0000000..4c90fd7 --- /dev/null +++ b/src/fonts4x6/char2e.bmp @@ -0,0 +1,3 @@ +#define char2e_width 4 +#define char2e_height 6 +static char char2e_bits[] = {0x00, 0x00, 0x00, 0x00, 0x04, 0x00}; diff --git a/src/fonts4x6/char2f.bmp b/src/fonts4x6/char2f.bmp new file mode 100755 index 0000000..7f3763d --- /dev/null +++ b/src/fonts4x6/char2f.bmp @@ -0,0 +1,3 @@ +#define char2f_width 4 +#define char2f_height 6 +static char char2f_bits[] = {0x02, 0x02, 0x04, 0x08, 0x08, 0x00}; diff --git a/src/fonts4x6/char30.bmp b/src/fonts4x6/char30.bmp new file mode 100755 index 0000000..eac63bb --- /dev/null +++ b/src/fonts4x6/char30.bmp @@ -0,0 +1,3 @@ +#define char30_width 4 +#define char30_height 6 +static char char30_bits[] = {0x04, 0x0e, 0x0e, 0x0e, 0x04, 0x00}; diff --git a/src/fonts4x6/char31.bmp b/src/fonts4x6/char31.bmp new file mode 100755 index 0000000..62b0c67 --- /dev/null +++ b/src/fonts4x6/char31.bmp @@ -0,0 +1,3 @@ +#define char31_width 4 +#define char31_height 6 +static char char31_bits[] = {0x04, 0x04, 0x04, 0x04, 0x04, 0x00}; diff --git a/src/fonts4x6/char32.bmp b/src/fonts4x6/char32.bmp new file mode 100755 index 0000000..a4c902e --- /dev/null +++ b/src/fonts4x6/char32.bmp @@ -0,0 +1,3 @@ +#define char32_width 4 +#define char32_height 6 +static char char32_bits[] = {0x04, 0x0a, 0x04, 0x0c, 0x0e, 0x00}; diff --git a/src/fonts4x6/char33.bmp b/src/fonts4x6/char33.bmp new file mode 100755 index 0000000..3319d4e --- /dev/null +++ b/src/fonts4x6/char33.bmp @@ -0,0 +1,3 @@ +#define char33_width 4 +#define char33_height 6 +static char char33_bits[] = {0x0e, 0x06, 0x04, 0x0a, 0x04, 0x00}; diff --git a/src/fonts4x6/char34.bmp b/src/fonts4x6/char34.bmp new file mode 100755 index 0000000..ccb7333 --- /dev/null +++ b/src/fonts4x6/char34.bmp @@ -0,0 +1,3 @@ +#define char34_width 4 +#define char34_height 6 +static char char34_bits[] = {0x04, 0x04, 0x0c, 0x0e, 0x04, 0x00}; diff --git a/src/fonts4x6/char35.bmp b/src/fonts4x6/char35.bmp new file mode 100755 index 0000000..3345d0c --- /dev/null +++ b/src/fonts4x6/char35.bmp @@ -0,0 +1,3 @@ +#define char35_width 4 +#define char35_height 6 +static char char35_bits[] = {0x0e, 0x0c, 0x02, 0x0a, 0x04, 0x00}; diff --git a/src/fonts4x6/char36.bmp b/src/fonts4x6/char36.bmp new file mode 100755 index 0000000..ce27db1 --- /dev/null +++ b/src/fonts4x6/char36.bmp @@ -0,0 +1,3 @@ +#define char36_width 4 +#define char36_height 6 +static char char36_bits[] = {0x06, 0x0c, 0x0c, 0x0a, 0x04, 0x00}; diff --git a/src/fonts4x6/char37.bmp b/src/fonts4x6/char37.bmp new file mode 100755 index 0000000..1695da9 --- /dev/null +++ b/src/fonts4x6/char37.bmp @@ -0,0 +1,3 @@ +#define char37_width 4 +#define char37_height 6 +static char char37_bits[] = {0x0e, 0x06, 0x04, 0x04, 0x04, 0x00}; diff --git a/src/fonts4x6/char38.bmp b/src/fonts4x6/char38.bmp new file mode 100755 index 0000000..0386de9 --- /dev/null +++ b/src/fonts4x6/char38.bmp @@ -0,0 +1,3 @@ +#define char38_width 4 +#define char38_height 6 +static char char38_bits[] = {0x04, 0x0a, 0x04, 0x0a, 0x04, 0x00}; diff --git a/src/fonts4x6/char39.bmp b/src/fonts4x6/char39.bmp new file mode 100755 index 0000000..d40385a --- /dev/null +++ b/src/fonts4x6/char39.bmp @@ -0,0 +1,3 @@ +#define char39_width 4 +#define char39_height 6 +static char char39_bits[] = {0x04, 0x0a, 0x06, 0x06, 0x0c, 0x00}; diff --git a/src/fonts4x6/char3a.bmp b/src/fonts4x6/char3a.bmp new file mode 100755 index 0000000..a76d020 --- /dev/null +++ b/src/fonts4x6/char3a.bmp @@ -0,0 +1,3 @@ +#define char3a_width 4 +#define char3a_height 6 +static char char3a_bits[] = {0x00, 0x04, 0x00, 0x04, 0x00, 0x00}; diff --git a/src/fonts4x6/char3b.bmp b/src/fonts4x6/char3b.bmp new file mode 100755 index 0000000..0af3f13 --- /dev/null +++ b/src/fonts4x6/char3b.bmp @@ -0,0 +1,3 @@ +#define char3b_width 4 +#define char3b_height 6 +static char char3b_bits[] = {0x00, 0x04, 0x00, 0x04, 0x04, 0x00}; diff --git a/src/fonts4x6/char3c.bmp b/src/fonts4x6/char3c.bmp new file mode 100755 index 0000000..d2c978f --- /dev/null +++ b/src/fonts4x6/char3c.bmp @@ -0,0 +1,3 @@ +#define char3c_width 4 +#define char3c_height 6 +static char char3c_bits[] = {0x04, 0x04, 0x08, 0x04, 0x04, 0x00}; diff --git a/src/fonts4x6/char3d.bmp b/src/fonts4x6/char3d.bmp new file mode 100755 index 0000000..3e8d262 --- /dev/null +++ b/src/fonts4x6/char3d.bmp @@ -0,0 +1,3 @@ +#define char3d_width 4 +#define char3d_height 6 +static char char3d_bits[] = {0x00, 0x0e, 0x00, 0x0e, 0x00, 0x00}; diff --git a/src/fonts4x6/char3e.bmp b/src/fonts4x6/char3e.bmp new file mode 100755 index 0000000..03de207 --- /dev/null +++ b/src/fonts4x6/char3e.bmp @@ -0,0 +1,3 @@ +#define char3e_width 4 +#define char3e_height 6 +static char char3e_bits[] = {0x04, 0x04, 0x02, 0x04, 0x04, 0x00}; diff --git a/src/fonts4x6/char3f.bmp b/src/fonts4x6/char3f.bmp new file mode 100755 index 0000000..8bf2f17 --- /dev/null +++ b/src/fonts4x6/char3f.bmp @@ -0,0 +1,3 @@ +#define char3f_width 4 +#define char3f_height 6 +static char char3f_bits[] = {0x04, 0x0e, 0x04, 0x04, 0x04, 0x00}; diff --git a/src/fonts4x6/char40.bmp b/src/fonts4x6/char40.bmp new file mode 100755 index 0000000..c3f541f --- /dev/null +++ b/src/fonts4x6/char40.bmp @@ -0,0 +1,3 @@ +#define char40_width 4 +#define char40_height 6 +static char char40_bits[] = {0x04, 0x04, 0x00, 0x00, 0x00, 0x00}; diff --git a/src/fonts4x6/char41.bmp b/src/fonts4x6/char41.bmp new file mode 100755 index 0000000..de5ccf0 --- /dev/null +++ b/src/fonts4x6/char41.bmp @@ -0,0 +1,3 @@ +#define char41_width 4 +#define char41_height 6 +static char char41_bits[] = {0x00, 0x04, 0x02, 0x0e, 0x06, 0x00}; diff --git a/src/fonts4x6/char42.bmp b/src/fonts4x6/char42.bmp new file mode 100755 index 0000000..0e14bad --- /dev/null +++ b/src/fonts4x6/char42.bmp @@ -0,0 +1,3 @@ +#define char42_width 4 +#define char42_height 6 +static char char42_bits[] = {0x08, 0x0c, 0x0a, 0x0a, 0x0c, 0x00}; diff --git a/src/fonts4x6/char43.bmp b/src/fonts4x6/char43.bmp new file mode 100755 index 0000000..92ac933 --- /dev/null +++ b/src/fonts4x6/char43.bmp @@ -0,0 +1,3 @@ +#define char43_width 4 +#define char43_height 6 +static char char43_bits[] = {0x00, 0x06, 0x08, 0x08, 0x06, 0x00}; diff --git a/src/fonts4x6/char44.bmp b/src/fonts4x6/char44.bmp new file mode 100755 index 0000000..4084c6b --- /dev/null +++ b/src/fonts4x6/char44.bmp @@ -0,0 +1,3 @@ +#define char44_width 4 +#define char44_height 6 +static char char44_bits[] = {0x02, 0x06, 0x0a, 0x0a, 0x06, 0x00}; diff --git a/src/fonts4x6/char45.bmp b/src/fonts4x6/char45.bmp new file mode 100755 index 0000000..bd387b8 --- /dev/null +++ b/src/fonts4x6/char45.bmp @@ -0,0 +1,3 @@ +#define char45_width 4 +#define char45_height 6 +static char char45_bits[] = {0x00, 0x04, 0x0a, 0x0e, 0x06, 0x00}; diff --git a/src/fonts4x6/char46.bmp b/src/fonts4x6/char46.bmp new file mode 100755 index 0000000..a388fd5 --- /dev/null +++ b/src/fonts4x6/char46.bmp @@ -0,0 +1,3 @@ +#define char46_width 4 +#define char46_height 6 +static char char46_bits[] = {0x04, 0x06, 0x0c, 0x04, 0x04, 0x00}; diff --git a/src/fonts4x6/char47.bmp b/src/fonts4x6/char47.bmp new file mode 100755 index 0000000..cec0923 --- /dev/null +++ b/src/fonts4x6/char47.bmp @@ -0,0 +1,3 @@ +#define char47_width 4 +#define char47_height 6 +static char char47_bits[] = {0x00, 0x04, 0x0a, 0x0e, 0x02, 0x04}; diff --git a/src/fonts4x6/char48.bmp b/src/fonts4x6/char48.bmp new file mode 100755 index 0000000..eb9ed99 --- /dev/null +++ b/src/fonts4x6/char48.bmp @@ -0,0 +1,3 @@ +#define char48_width 4 +#define char48_height 6 +static char char48_bits[] = {0x08, 0x0c, 0x0a, 0x0a, 0x0a, 0x00}; diff --git a/src/fonts4x6/char49.bmp b/src/fonts4x6/char49.bmp new file mode 100755 index 0000000..ac607e8 --- /dev/null +++ b/src/fonts4x6/char49.bmp @@ -0,0 +1,3 @@ +#define char49_width 4 +#define char49_height 6 +static char char49_bits[] = {0x04, 0x00, 0x04, 0x04, 0x04, 0x00}; diff --git a/src/fonts4x6/char4a.bmp b/src/fonts4x6/char4a.bmp new file mode 100755 index 0000000..87e6f98 --- /dev/null +++ b/src/fonts4x6/char4a.bmp @@ -0,0 +1,3 @@ +#define char4a_width 4 +#define char4a_height 6 +static char char4a_bits[] = {0x04, 0x04, 0x04, 0x04, 0x0c, 0x04}; diff --git a/src/fonts4x6/char4b.bmp b/src/fonts4x6/char4b.bmp new file mode 100755 index 0000000..98ee6dc --- /dev/null +++ b/src/fonts4x6/char4b.bmp @@ -0,0 +1,3 @@ +#define char4b_width 4 +#define char4b_height 6 +static char char4b_bits[] = {0x08, 0x0a, 0x0c, 0x0c, 0x0a, 0x00}; diff --git a/src/fonts4x6/char4c.bmp b/src/fonts4x6/char4c.bmp new file mode 100755 index 0000000..e90525c --- /dev/null +++ b/src/fonts4x6/char4c.bmp @@ -0,0 +1,3 @@ +#define char4c_width 4 +#define char4c_height 6 +static char char4c_bits[] = {0x04, 0x04, 0x04, 0x04, 0x04, 0x00}; diff --git a/src/fonts4x6/char4d.bmp b/src/fonts4x6/char4d.bmp new file mode 100755 index 0000000..04d09a4 --- /dev/null +++ b/src/fonts4x6/char4d.bmp @@ -0,0 +1,3 @@ +#define char4d_width 4 +#define char4d_height 6 +static char char4d_bits[] = {0x00, 0x0e, 0x0e, 0x0e, 0x0a, 0x00}; diff --git a/src/fonts4x6/char4e.bmp b/src/fonts4x6/char4e.bmp new file mode 100755 index 0000000..85a4ea2 --- /dev/null +++ b/src/fonts4x6/char4e.bmp @@ -0,0 +1,3 @@ +#define char4e_width 4 +#define char4e_height 6 +static char char4e_bits[] = {0x00, 0x0c, 0x0a, 0x0a, 0x0a, 0x00}; diff --git a/src/fonts4x6/char4f.bmp b/src/fonts4x6/char4f.bmp new file mode 100755 index 0000000..76c50c6 --- /dev/null +++ b/src/fonts4x6/char4f.bmp @@ -0,0 +1,3 @@ +#define char4f_width 4 +#define char4f_height 6 +static char char4f_bits[] = {0x00, 0x04, 0x0a, 0x0a, 0x04, 0x00}; diff --git a/src/fonts4x6/char50.bmp b/src/fonts4x6/char50.bmp new file mode 100755 index 0000000..d2ddb47 --- /dev/null +++ b/src/fonts4x6/char50.bmp @@ -0,0 +1,3 @@ +#define char50_width 4 +#define char50_height 6 +static char char50_bits[] = {0x00, 0x0c, 0x0a, 0x0e, 0x08, 0x08}; diff --git a/src/fonts4x6/char51.bmp b/src/fonts4x6/char51.bmp new file mode 100755 index 0000000..ad60742 --- /dev/null +++ b/src/fonts4x6/char51.bmp @@ -0,0 +1,3 @@ +#define char51_width 4 +#define char51_height 6 +static char char51_bits[] = {0x00, 0x06, 0x0a, 0x0e, 0x02, 0x02}; diff --git a/src/fonts4x6/char52.bmp b/src/fonts4x6/char52.bmp new file mode 100755 index 0000000..bba8ba8 --- /dev/null +++ b/src/fonts4x6/char52.bmp @@ -0,0 +1,3 @@ +#define char52_width 4 +#define char52_height 6 +static char char52_bits[] = {0x00, 0x0e, 0x0c, 0x08, 0x08, 0x00}; diff --git a/src/fonts4x6/char53.bmp b/src/fonts4x6/char53.bmp new file mode 100755 index 0000000..02215a7 --- /dev/null +++ b/src/fonts4x6/char53.bmp @@ -0,0 +1,3 @@ +#define char53_width 4 +#define char53_height 6 +static char char53_bits[] = {0x00, 0x06, 0x08, 0x06, 0x0c, 0x00}; diff --git a/src/fonts4x6/char54.bmp b/src/fonts4x6/char54.bmp new file mode 100755 index 0000000..4f5c218 --- /dev/null +++ b/src/fonts4x6/char54.bmp @@ -0,0 +1,3 @@ +#define char54_width 4 +#define char54_height 6 +static char char54_bits[] = {0x04, 0x0c, 0x04, 0x06, 0x04, 0x00}; diff --git a/src/fonts4x6/char55.bmp b/src/fonts4x6/char55.bmp new file mode 100755 index 0000000..83f81f8 --- /dev/null +++ b/src/fonts4x6/char55.bmp @@ -0,0 +1,3 @@ +#define char55_width 4 +#define char55_height 6 +static char char55_bits[] = {0x00, 0x0a, 0x0a, 0x0e, 0x06, 0x00}; diff --git a/src/fonts4x6/char56.bmp b/src/fonts4x6/char56.bmp new file mode 100755 index 0000000..46ecaa2 --- /dev/null +++ b/src/fonts4x6/char56.bmp @@ -0,0 +1,3 @@ +#define char56_width 4 +#define char56_height 6 +static char char56_bits[] = {0x00, 0x0a, 0x0a, 0x0e, 0x04, 0x00}; diff --git a/src/fonts4x6/char57.bmp b/src/fonts4x6/char57.bmp new file mode 100755 index 0000000..482e007 --- /dev/null +++ b/src/fonts4x6/char57.bmp @@ -0,0 +1,3 @@ +#define char57_width 4 +#define char57_height 6 +static char char57_bits[] = {0x00, 0x0a, 0x0a, 0x0e, 0x0e, 0x00}; diff --git a/src/fonts4x6/char58.bmp b/src/fonts4x6/char58.bmp new file mode 100755 index 0000000..bcd91c7 --- /dev/null +++ b/src/fonts4x6/char58.bmp @@ -0,0 +1,3 @@ +#define char58_width 4 +#define char58_height 6 +static char char58_bits[] = {0x00, 0x0a, 0x04, 0x04, 0x0a, 0x00}; diff --git a/src/fonts4x6/char59.bmp b/src/fonts4x6/char59.bmp new file mode 100755 index 0000000..0f1fc94 --- /dev/null +++ b/src/fonts4x6/char59.bmp @@ -0,0 +1,3 @@ +#define char59_width 4 +#define char59_height 6 +static char char59_bits[] = {0x00, 0x0a, 0x0a, 0x0e, 0x02, 0x04}; diff --git a/src/fonts4x6/char5a.bmp b/src/fonts4x6/char5a.bmp new file mode 100755 index 0000000..0c556c3 --- /dev/null +++ b/src/fonts4x6/char5a.bmp @@ -0,0 +1,3 @@ +#define char5a_width 4 +#define char5a_height 6 +static char char5a_bits[] = {0x00, 0x0e, 0x04, 0x04, 0x0e, 0x00}; diff --git a/src/fonts4x6/char5b.bmp b/src/fonts4x6/char5b.bmp new file mode 100755 index 0000000..9739cc4 --- /dev/null +++ b/src/fonts4x6/char5b.bmp @@ -0,0 +1,3 @@ +#define char5b_width 4 +#define char5b_height 6 +static char char5b_bits[] = {0x06, 0x04, 0x0c, 0x04, 0x06, 0x00}; diff --git a/src/fonts4x6/char5c.bmp b/src/fonts4x6/char5c.bmp new file mode 100755 index 0000000..70d0a13 --- /dev/null +++ b/src/fonts4x6/char5c.bmp @@ -0,0 +1,3 @@ +#define char5c_width 4 +#define char5c_height 6 +static char char5c_bits[] = {0x04, 0x04, 0x04, 0x04, 0x04, 0x04}; diff --git a/src/fonts4x6/char5d.bmp b/src/fonts4x6/char5d.bmp new file mode 100755 index 0000000..116fbe8 --- /dev/null +++ b/src/fonts4x6/char5d.bmp @@ -0,0 +1,3 @@ +#define char5d_width 4 +#define char5d_height 6 +static char char5d_bits[] = {0x0c, 0x04, 0x06, 0x04, 0x0c, 0x00}; diff --git a/src/fonts4x6/char5e.bmp b/src/fonts4x6/char5e.bmp new file mode 100755 index 0000000..06510bb --- /dev/null +++ b/src/fonts4x6/char5e.bmp @@ -0,0 +1,3 @@ +#define char5e_width 4 +#define char5e_height 6 +static char char5e_bits[] = {0x04, 0x0e, 0x00, 0x00, 0x00, 0x00}; diff --git a/src/fonts4x6/char5f.bmp b/src/fonts4x6/char5f.bmp new file mode 100755 index 0000000..7a60d38 --- /dev/null +++ b/src/fonts4x6/char5f.bmp @@ -0,0 +1,3 @@ +#define char5f_width 4 +#define char5f_height 6 +static char char5f_bits[] = {0x00, 0x0e, 0x0e, 0x0e, 0x00, 0x00}; diff --git a/src/fonts7x8.c b/src/fonts7x8.c new file mode 100755 index 0000000..4d994db --- /dev/null +++ b/src/fonts7x8.c @@ -0,0 +1,137 @@ +/* + * fonts.c + */ + +/* + * apple fonts bitmap files + */ + +#include "fonts7x8/char00.bmp" +#include "fonts7x8/char01.bmp" +#include "fonts7x8/char02.bmp" +#include "fonts7x8/char03.bmp" +#include "fonts7x8/char04.bmp" +#include "fonts7x8/char05.bmp" +#include "fonts7x8/char06.bmp" +#include "fonts7x8/char07.bmp" +#include "fonts7x8/char08.bmp" +#include "fonts7x8/char09.bmp" +#include "fonts7x8/char0a.bmp" +#include "fonts7x8/char0b.bmp" +#include "fonts7x8/char0c.bmp" +#include "fonts7x8/char0d.bmp" +#include "fonts7x8/char0e.bmp" +#include "fonts7x8/char0f.bmp" +#include "fonts7x8/char10.bmp" +#include "fonts7x8/char11.bmp" +#include "fonts7x8/char12.bmp" +#include "fonts7x8/char13.bmp" +#include "fonts7x8/char14.bmp" +#include "fonts7x8/char15.bmp" +#include "fonts7x8/char16.bmp" +#include "fonts7x8/char17.bmp" +#include "fonts7x8/char18.bmp" +#include "fonts7x8/char19.bmp" +#include "fonts7x8/char1a.bmp" +#include "fonts7x8/char1b.bmp" +#include "fonts7x8/char1c.bmp" +#include "fonts7x8/char1d.bmp" +#include "fonts7x8/char1e.bmp" +#include "fonts7x8/char1f.bmp" +#include "fonts7x8/char20.bmp" +#include "fonts7x8/char21.bmp" +#include "fonts7x8/char22.bmp" +#include "fonts7x8/char23.bmp" +#include "fonts7x8/char24.bmp" +#include "fonts7x8/char25.bmp" +#include "fonts7x8/char26.bmp" +#include "fonts7x8/char27.bmp" +#include "fonts7x8/char28.bmp" +#include "fonts7x8/char29.bmp" +#include "fonts7x8/char2a.bmp" +#include "fonts7x8/char2b.bmp" +#include "fonts7x8/char2c.bmp" +#include "fonts7x8/char2d.bmp" +#include "fonts7x8/char2e.bmp" +#include "fonts7x8/char2f.bmp" +#include "fonts7x8/char30.bmp" +#include "fonts7x8/char31.bmp" +#include "fonts7x8/char32.bmp" +#include "fonts7x8/char33.bmp" +#include "fonts7x8/char34.bmp" +#include "fonts7x8/char35.bmp" +#include "fonts7x8/char36.bmp" +#include "fonts7x8/char37.bmp" +#include "fonts7x8/char38.bmp" +#include "fonts7x8/char39.bmp" +#include "fonts7x8/char3a.bmp" +#include "fonts7x8/char3b.bmp" +#include "fonts7x8/char3c.bmp" +#include "fonts7x8/char3d.bmp" +#include "fonts7x8/char3e.bmp" +#include "fonts7x8/char3f.bmp" +#include "fonts7x8/char40.bmp" +#include "fonts7x8/char41.bmp" +#include "fonts7x8/char42.bmp" +#include "fonts7x8/char43.bmp" +#include "fonts7x8/char44.bmp" +#include "fonts7x8/char45.bmp" +#include "fonts7x8/char46.bmp" +#include "fonts7x8/char47.bmp" +#include "fonts7x8/char48.bmp" +#include "fonts7x8/char49.bmp" +#include "fonts7x8/char4a.bmp" +#include "fonts7x8/char4b.bmp" +#include "fonts7x8/char4c.bmp" +#include "fonts7x8/char4d.bmp" +#include "fonts7x8/char4e.bmp" +#include "fonts7x8/char4f.bmp" +#include "fonts7x8/char50.bmp" +#include "fonts7x8/char51.bmp" +#include "fonts7x8/char52.bmp" +#include "fonts7x8/char53.bmp" +#include "fonts7x8/char54.bmp" +#include "fonts7x8/char55.bmp" +#include "fonts7x8/char56.bmp" +#include "fonts7x8/char57.bmp" +#include "fonts7x8/char58.bmp" +#include "fonts7x8/char59.bmp" +#include "fonts7x8/char5a.bmp" +#include "fonts7x8/char5b.bmp" +#include "fonts7x8/char5c.bmp" +#include "fonts7x8/char5d.bmp" +#include "fonts7x8/char5e.bmp" +#include "fonts7x8/char5f.bmp" + +/* + * bitmap index array + */ + +#define MAX_CHAR_BITMAP 0x60 + +char *AppleFontBitmap7x8[MAX_CHAR_BITMAP] = { + char00_bits, char01_bits, char02_bits, char03_bits, + char04_bits, char05_bits, char06_bits, char07_bits, + char08_bits, char09_bits, char0a_bits, char0b_bits, + char0c_bits, char0d_bits, char0e_bits, char0f_bits, + char10_bits, char11_bits, char12_bits, char13_bits, + char14_bits, char15_bits, char16_bits, char17_bits, + char18_bits, char19_bits, char1a_bits, char1b_bits, + char1c_bits, char1d_bits, char1e_bits, char1f_bits, + char20_bits, char21_bits, char22_bits, char23_bits, + char24_bits, char25_bits, char26_bits, char27_bits, + char28_bits, char29_bits, char2a_bits, char2b_bits, + char2c_bits, char2d_bits, char2e_bits, char2f_bits, + char30_bits, char31_bits, char32_bits, char33_bits, + char34_bits, char35_bits, char36_bits, char37_bits, + char38_bits, char39_bits, char3a_bits, char3b_bits, + char3c_bits, char3d_bits, char3e_bits, char3f_bits, + char40_bits, char41_bits, char42_bits, char43_bits, + char44_bits, char45_bits, char46_bits, char47_bits, + char48_bits, char49_bits, char4a_bits, char4b_bits, + char4c_bits, char4d_bits, char4e_bits, char4f_bits, + char50_bits, char51_bits, char52_bits, char53_bits, + char54_bits, char55_bits, char56_bits, char57_bits, + char58_bits, char59_bits, char5a_bits, char5b_bits, + char5c_bits, char5d_bits, char5e_bits, char5f_bits, +}; diff --git a/src/fonts7x8/CVS/Entries b/src/fonts7x8/CVS/Entries new file mode 100644 index 0000000..4ea3a7b --- /dev/null +++ b/src/fonts7x8/CVS/Entries @@ -0,0 +1,98 @@ +/char00.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char01.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char02.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char03.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char04.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char05.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char06.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char07.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char08.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char09.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char0a.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char0b.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char0c.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char0d.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char0e.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char0f.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char10.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char11.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char12.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char13.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char14.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char15.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char16.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char17.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char18.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char19.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char1a.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char1b.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char1c.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char1d.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char1e.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char1f.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char20.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char21.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char22.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char23.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char24.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char25.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char26.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char27.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char28.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char29.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char2a.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char2b.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char2c.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char2d.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char2e.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char2f.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char30.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char31.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char32.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char33.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char34.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char35.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char36.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char37.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char38.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char39.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char3a.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char3b.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char3c.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char3d.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char3e.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char3f.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char40.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char41.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char42.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char43.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char44.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char45.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char46.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char47.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char48.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char49.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char4a.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char4b.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char4c.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char4d.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char4e.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char4f.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char50.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char51.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char52.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char53.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char54.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char55.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char56.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char57.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char58.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char59.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char5a.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char5b.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char5c.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char5d.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char5e.bmp/1.1/Tue Jun 17 04:40:38 2003// +/char5f.bmp/1.1/Tue Jun 17 04:40:38 2003// +/lowres.bmp/1.1/Tue Jun 17 04:40:38 2003// +D diff --git a/src/fonts7x8/CVS/Repository b/src/fonts7x8/CVS/Repository new file mode 100644 index 0000000..d230ccf --- /dev/null +++ b/src/fonts7x8/CVS/Repository @@ -0,0 +1 @@ +palmapple/src/fonts7x8 diff --git a/src/fonts7x8/CVS/Root b/src/fonts7x8/CVS/Root new file mode 100644 index 0000000..bdb6620 --- /dev/null +++ b/src/fonts7x8/CVS/Root @@ -0,0 +1 @@ +:ext:dschmenk@cvs.sourceforge.net:/cvsroot/palmapple diff --git a/src/fonts7x8/char00.bmp b/src/fonts7x8/char00.bmp new file mode 100755 index 0000000..bf67cf3 --- /dev/null +++ b/src/fonts7x8/char00.bmp @@ -0,0 +1,3 @@ +#define char00_width 7 +#define char00_height 8 +static char char00_bits[] = {0x3c, 0x44, 0x54, 0x5c, 0x58, 0x40, 0x3c, 0x0}; diff --git a/src/fonts7x8/char01.bmp b/src/fonts7x8/char01.bmp new file mode 100755 index 0000000..ef8e7cc --- /dev/null +++ b/src/fonts7x8/char01.bmp @@ -0,0 +1,3 @@ +#define char01_width 7 +#define char01_height 8 +static char char01_bits[] = {0x10, 0x28, 0x44, 0x44, 0x7c, 0x44, 0x44, 0x0}; diff --git a/src/fonts7x8/char02.bmp b/src/fonts7x8/char02.bmp new file mode 100755 index 0000000..7acd18c --- /dev/null +++ b/src/fonts7x8/char02.bmp @@ -0,0 +1,3 @@ +#define char02_width 7 +#define char02_height 8 +static char char02_bits[] = {0x78, 0x44, 0x44, 0x78, 0x44, 0x44, 0x78, 0x0}; diff --git a/src/fonts7x8/char03.bmp b/src/fonts7x8/char03.bmp new file mode 100755 index 0000000..77ca0ae --- /dev/null +++ b/src/fonts7x8/char03.bmp @@ -0,0 +1,3 @@ +#define char03_width 7 +#define char03_height 8 +static char char03_bits[] = {0x38, 0x44, 0x40, 0x40, 0x40, 0x44, 0x38, 0x0}; diff --git a/src/fonts7x8/char04.bmp b/src/fonts7x8/char04.bmp new file mode 100755 index 0000000..aab816e --- /dev/null +++ b/src/fonts7x8/char04.bmp @@ -0,0 +1,3 @@ +#define char04_width 7 +#define char04_height 8 +static char char04_bits[] = {0x78, 0x44, 0x44, 0x44, 0x44, 0x44, 0x78, 0x0}; diff --git a/src/fonts7x8/char05.bmp b/src/fonts7x8/char05.bmp new file mode 100755 index 0000000..54e57e2 --- /dev/null +++ b/src/fonts7x8/char05.bmp @@ -0,0 +1,3 @@ +#define char05_width 7 +#define char05_height 8 +static char char05_bits[] = {0x7c, 0x40, 0x40, 0x78, 0x40, 0x40, 0x7c, 0x0}; diff --git a/src/fonts7x8/char06.bmp b/src/fonts7x8/char06.bmp new file mode 100755 index 0000000..19f9314 --- /dev/null +++ b/src/fonts7x8/char06.bmp @@ -0,0 +1,3 @@ +#define char06_width 7 +#define char06_height 8 +static char char06_bits[] = {0x7c, 0x40, 0x40, 0x78, 0x40, 0x40, 0x40, 0x0}; diff --git a/src/fonts7x8/char07.bmp b/src/fonts7x8/char07.bmp new file mode 100755 index 0000000..3f82f91 --- /dev/null +++ b/src/fonts7x8/char07.bmp @@ -0,0 +1,3 @@ +#define char07_width 7 +#define char07_height 8 +static char char07_bits[] = {0x3c, 0x40, 0x40, 0x40, 0x4c, 0x44, 0x3c, 0x0}; diff --git a/src/fonts7x8/char08.bmp b/src/fonts7x8/char08.bmp new file mode 100755 index 0000000..88ddb3c --- /dev/null +++ b/src/fonts7x8/char08.bmp @@ -0,0 +1,3 @@ +#define char08_width 7 +#define char08_height 8 +static char char08_bits[] = {0x44, 0x44, 0x44, 0x7c, 0x44, 0x44, 0x44, 0x0}; diff --git a/src/fonts7x8/char09.bmp b/src/fonts7x8/char09.bmp new file mode 100755 index 0000000..b2fa749 --- /dev/null +++ b/src/fonts7x8/char09.bmp @@ -0,0 +1,3 @@ +#define char09_width 7 +#define char09_height 8 +static char char09_bits[] = {0x38, 0x10, 0x10, 0x10, 0x10, 0x10, 0x38, 0x0}; diff --git a/src/fonts7x8/char0a.bmp b/src/fonts7x8/char0a.bmp new file mode 100755 index 0000000..aa55bc1 --- /dev/null +++ b/src/fonts7x8/char0a.bmp @@ -0,0 +1,3 @@ +#define char0a_width 7 +#define char0a_height 8 +static char char0a_bits[] = {0x4, 0x4, 0x4, 0x4, 0x4, 0x44, 0x38, 0x0}; diff --git a/src/fonts7x8/char0b.bmp b/src/fonts7x8/char0b.bmp new file mode 100755 index 0000000..5bc5025 --- /dev/null +++ b/src/fonts7x8/char0b.bmp @@ -0,0 +1,3 @@ +#define char0b_width 7 +#define char0b_height 8 +static char char0b_bits[] = {0x44, 0x48, 0x50, 0x60, 0x50, 0x48, 0x44, 0x0}; diff --git a/src/fonts7x8/char0c.bmp b/src/fonts7x8/char0c.bmp new file mode 100755 index 0000000..96fc2ff --- /dev/null +++ b/src/fonts7x8/char0c.bmp @@ -0,0 +1,3 @@ +#define char0c_width 7 +#define char0c_height 8 +static char char0c_bits[] = {0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7c, 0x0}; diff --git a/src/fonts7x8/char0d.bmp b/src/fonts7x8/char0d.bmp new file mode 100755 index 0000000..3e1a630 --- /dev/null +++ b/src/fonts7x8/char0d.bmp @@ -0,0 +1,3 @@ +#define char0d_width 7 +#define char0d_height 8 +static char char0d_bits[] = {0x44, 0x6c, 0x54, 0x54, 0x44, 0x44, 0x44, 0x0}; diff --git a/src/fonts7x8/char0e.bmp b/src/fonts7x8/char0e.bmp new file mode 100755 index 0000000..6191c62 --- /dev/null +++ b/src/fonts7x8/char0e.bmp @@ -0,0 +1,3 @@ +#define char0e_width 7 +#define char0e_height 8 +static char char0e_bits[] = {0x44, 0x44, 0x64, 0x54, 0x4c, 0x44, 0x44, 0x0}; diff --git a/src/fonts7x8/char0f.bmp b/src/fonts7x8/char0f.bmp new file mode 100755 index 0000000..108f9e7 --- /dev/null +++ b/src/fonts7x8/char0f.bmp @@ -0,0 +1,3 @@ +#define char0f_width 7 +#define char0f_height 8 +static char char0f_bits[] = {0x38, 0x44, 0x44, 0x44, 0x44, 0x44, 0x38, 0x0}; diff --git a/src/fonts7x8/char10.bmp b/src/fonts7x8/char10.bmp new file mode 100755 index 0000000..db07369 --- /dev/null +++ b/src/fonts7x8/char10.bmp @@ -0,0 +1,3 @@ +#define char10_width 7 +#define char10_height 8 +static char char10_bits[] = {0x78, 0x44, 0x44, 0x78, 0x40, 0x40, 0x40, 0x0}; diff --git a/src/fonts7x8/char11.bmp b/src/fonts7x8/char11.bmp new file mode 100755 index 0000000..0cb95fc --- /dev/null +++ b/src/fonts7x8/char11.bmp @@ -0,0 +1,3 @@ +#define char11_width 7 +#define char11_height 8 +static char char11_bits[] = {0x38, 0x44, 0x44, 0x44, 0x54, 0x48, 0x34, 0x0}; diff --git a/src/fonts7x8/char12.bmp b/src/fonts7x8/char12.bmp new file mode 100755 index 0000000..ed50cd8 --- /dev/null +++ b/src/fonts7x8/char12.bmp @@ -0,0 +1,3 @@ +#define char12_width 7 +#define char12_height 8 +static char char12_bits[] = {0x78, 0x44, 0x44, 0x78, 0x50, 0x48, 0x44, 0x0}; diff --git a/src/fonts7x8/char13.bmp b/src/fonts7x8/char13.bmp new file mode 100755 index 0000000..8d35d0a --- /dev/null +++ b/src/fonts7x8/char13.bmp @@ -0,0 +1,3 @@ +#define char13_width 7 +#define char13_height 8 +static char char13_bits[] = {0x38, 0x44, 0x40, 0x38, 0x4, 0x44, 0x38, 0x0}; diff --git a/src/fonts7x8/char14.bmp b/src/fonts7x8/char14.bmp new file mode 100755 index 0000000..28ed855 --- /dev/null +++ b/src/fonts7x8/char14.bmp @@ -0,0 +1,3 @@ +#define char14_width 7 +#define char14_height 8 +static char char14_bits[] = {0x7c, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x0}; diff --git a/src/fonts7x8/char15.bmp b/src/fonts7x8/char15.bmp new file mode 100755 index 0000000..70e4e70 --- /dev/null +++ b/src/fonts7x8/char15.bmp @@ -0,0 +1,3 @@ +#define char15_width 7 +#define char15_height 8 +static char char15_bits[] = {0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x38, 0x0}; diff --git a/src/fonts7x8/char16.bmp b/src/fonts7x8/char16.bmp new file mode 100755 index 0000000..410dd20 --- /dev/null +++ b/src/fonts7x8/char16.bmp @@ -0,0 +1,3 @@ +#define char16_width 7 +#define char16_height 8 +static char char16_bits[] = {0x44, 0x44, 0x44, 0x44, 0x44, 0x28, 0x10, 0x0}; diff --git a/src/fonts7x8/char17.bmp b/src/fonts7x8/char17.bmp new file mode 100755 index 0000000..d1b893f --- /dev/null +++ b/src/fonts7x8/char17.bmp @@ -0,0 +1,3 @@ +#define char17_width 7 +#define char17_height 8 +static char char17_bits[] = {0x44, 0x44, 0x44, 0x54, 0x54, 0x6c, 0x44, 0x0}; diff --git a/src/fonts7x8/char18.bmp b/src/fonts7x8/char18.bmp new file mode 100755 index 0000000..befbc75 --- /dev/null +++ b/src/fonts7x8/char18.bmp @@ -0,0 +1,3 @@ +#define char18_width 7 +#define char18_height 8 +static char char18_bits[] = {0x44, 0x44, 0x28, 0x10, 0x28, 0x44, 0x44, 0x0}; diff --git a/src/fonts7x8/char19.bmp b/src/fonts7x8/char19.bmp new file mode 100755 index 0000000..d993a17 --- /dev/null +++ b/src/fonts7x8/char19.bmp @@ -0,0 +1,3 @@ +#define char19_width 7 +#define char19_height 8 +static char char19_bits[] = {0x44, 0x44, 0x28, 0x10, 0x10, 0x10, 0x10, 0x0}; diff --git a/src/fonts7x8/char1a.bmp b/src/fonts7x8/char1a.bmp new file mode 100755 index 0000000..9904bfb --- /dev/null +++ b/src/fonts7x8/char1a.bmp @@ -0,0 +1,3 @@ +#define char1a_width 7 +#define char1a_height 8 +static char char1a_bits[] = {0x7c, 0x4, 0x8, 0x10, 0x20, 0x40, 0x7c, 0x0}; diff --git a/src/fonts7x8/char1b.bmp b/src/fonts7x8/char1b.bmp new file mode 100755 index 0000000..28863dc --- /dev/null +++ b/src/fonts7x8/char1b.bmp @@ -0,0 +1,3 @@ +#define char1b_width 7 +#define char1b_height 8 +static char char1b_bits[] = {0x7c, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7c, 0x0}; diff --git a/src/fonts7x8/char1c.bmp b/src/fonts7x8/char1c.bmp new file mode 100755 index 0000000..12134f6 --- /dev/null +++ b/src/fonts7x8/char1c.bmp @@ -0,0 +1,3 @@ +#define char1c_width 7 +#define char1c_height 8 +static char char1c_bits[] = {0x0, 0x40, 0x20, 0x10, 0x8, 0x4, 0x0, 0x0}; diff --git a/src/fonts7x8/char1d.bmp b/src/fonts7x8/char1d.bmp new file mode 100755 index 0000000..76ae7fd --- /dev/null +++ b/src/fonts7x8/char1d.bmp @@ -0,0 +1,3 @@ +#define char1d_width 7 +#define char1d_height 8 +static char char1d_bits[] = {0x7c, 0xc, 0xc, 0xc, 0xc, 0xc, 0x7c, 0x0}; diff --git a/src/fonts7x8/char1e.bmp b/src/fonts7x8/char1e.bmp new file mode 100755 index 0000000..de0dbba --- /dev/null +++ b/src/fonts7x8/char1e.bmp @@ -0,0 +1,3 @@ +#define char1e_width 7 +#define char1e_height 8 +static char char1e_bits[] = {0x0, 0x0, 0x10, 0x28, 0x44, 0x0, 0x0, 0x0}; diff --git a/src/fonts7x8/char1f.bmp b/src/fonts7x8/char1f.bmp new file mode 100755 index 0000000..a8a4bcf --- /dev/null +++ b/src/fonts7x8/char1f.bmp @@ -0,0 +1,3 @@ +#define char1f_width 7 +#define char1f_height 8 +static char char1f_bits[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe}; diff --git a/src/fonts7x8/char20.bmp b/src/fonts7x8/char20.bmp new file mode 100755 index 0000000..8f6e25a --- /dev/null +++ b/src/fonts7x8/char20.bmp @@ -0,0 +1,3 @@ +#define char20_width 7 +#define char20_height 8 +static char char20_bits[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; diff --git a/src/fonts7x8/char21.bmp b/src/fonts7x8/char21.bmp new file mode 100755 index 0000000..537b571 --- /dev/null +++ b/src/fonts7x8/char21.bmp @@ -0,0 +1,3 @@ +#define char21_width 7 +#define char21_height 8 +static char char21_bits[] = {0x10, 0x10, 0x10, 0x10, 0x10, 0x0, 0x10, 0x0}; diff --git a/src/fonts7x8/char22.bmp b/src/fonts7x8/char22.bmp new file mode 100755 index 0000000..f4fceb4 --- /dev/null +++ b/src/fonts7x8/char22.bmp @@ -0,0 +1,3 @@ +#define char22_width 7 +#define char22_height 8 +static char char22_bits[] = {0x28, 0x28, 0x28, 0x0, 0x0, 0x0, 0x0, 0x0}; diff --git a/src/fonts7x8/char23.bmp b/src/fonts7x8/char23.bmp new file mode 100755 index 0000000..a851d21 --- /dev/null +++ b/src/fonts7x8/char23.bmp @@ -0,0 +1,3 @@ +#define char23_width 7 +#define char23_height 8 +static char char23_bits[] = {0x28, 0x28, 0xfe, 0x28, 0xfe, 0x28, 0x28, 0x0}; diff --git a/src/fonts7x8/char24.bmp b/src/fonts7x8/char24.bmp new file mode 100755 index 0000000..7c8d8f7 --- /dev/null +++ b/src/fonts7x8/char24.bmp @@ -0,0 +1,3 @@ +#define char24_width 7 +#define char24_height 8 +static char char24_bits[] = {0x10, 0x3c, 0x50, 0x38, 0x14, 0x78, 0x10, 0x0}; diff --git a/src/fonts7x8/char25.bmp b/src/fonts7x8/char25.bmp new file mode 100755 index 0000000..5687728 --- /dev/null +++ b/src/fonts7x8/char25.bmp @@ -0,0 +1,3 @@ +#define char25_width 7 +#define char25_height 8 +static char char25_bits[] = {0x60, 0x64, 0x8, 0x10, 0x20, 0x4c, 0xc, 0x0}; diff --git a/src/fonts7x8/char26.bmp b/src/fonts7x8/char26.bmp new file mode 100755 index 0000000..0f9387b --- /dev/null +++ b/src/fonts7x8/char26.bmp @@ -0,0 +1,3 @@ +#define char26_width 7 +#define char26_height 8 +static char char26_bits[] = {0x20, 0x50, 0x50, 0x20, 0x54, 0x48, 0x34, 0x0}; diff --git a/src/fonts7x8/char27.bmp b/src/fonts7x8/char27.bmp new file mode 100755 index 0000000..4b618ee --- /dev/null +++ b/src/fonts7x8/char27.bmp @@ -0,0 +1,3 @@ +#define char27_width 7 +#define char27_height 8 +static char char27_bits[] = {0x10, 0x10, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0}; diff --git a/src/fonts7x8/char28.bmp b/src/fonts7x8/char28.bmp new file mode 100755 index 0000000..aedef66 --- /dev/null +++ b/src/fonts7x8/char28.bmp @@ -0,0 +1,3 @@ +#define char28_width 7 +#define char28_height 8 +static char char28_bits[] = {0x10, 0x20, 0x40, 0x40, 0x40, 0x20, 0x10, 0x0}; diff --git a/src/fonts7x8/char29.bmp b/src/fonts7x8/char29.bmp new file mode 100755 index 0000000..4394755 --- /dev/null +++ b/src/fonts7x8/char29.bmp @@ -0,0 +1,3 @@ +#define char29_width 7 +#define char29_height 8 +static char char29_bits[] = {0x10, 0x8, 0x4, 0x4, 0x4, 0x8, 0x10, 0x0}; diff --git a/src/fonts7x8/char2a.bmp b/src/fonts7x8/char2a.bmp new file mode 100755 index 0000000..75310b1 --- /dev/null +++ b/src/fonts7x8/char2a.bmp @@ -0,0 +1,3 @@ +#define char2a_width 7 +#define char2a_height 8 +static char char2a_bits[] = {0x10, 0x54, 0x38, 0x10, 0x38, 0x54, 0x10, 0x0}; diff --git a/src/fonts7x8/char2b.bmp b/src/fonts7x8/char2b.bmp new file mode 100755 index 0000000..fc5bfb6 --- /dev/null +++ b/src/fonts7x8/char2b.bmp @@ -0,0 +1,3 @@ +#define char2b_width 7 +#define char2b_height 8 +static char char2b_bits[] = {0x0, 0x10, 0x10, 0x7c, 0x10, 0x10, 0x0, 0x0}; diff --git a/src/fonts7x8/char2c.bmp b/src/fonts7x8/char2c.bmp new file mode 100755 index 0000000..f901639 --- /dev/null +++ b/src/fonts7x8/char2c.bmp @@ -0,0 +1,3 @@ +#define char2c_width 7 +#define char2c_height 8 +static char char2c_bits[] = {0x0, 0x0, 0x0, 0x0, 0x10, 0x10, 0x20, 0x0}; diff --git a/src/fonts7x8/char2d.bmp b/src/fonts7x8/char2d.bmp new file mode 100755 index 0000000..fede6fc --- /dev/null +++ b/src/fonts7x8/char2d.bmp @@ -0,0 +1,3 @@ +#define char2d_width 7 +#define char2d_height 8 +static char char2d_bits[] = {0x0, 0x0, 0x0, 0x7c, 0x0, 0x0, 0x0, 0x0}; diff --git a/src/fonts7x8/char2e.bmp b/src/fonts7x8/char2e.bmp new file mode 100755 index 0000000..65fe23c --- /dev/null +++ b/src/fonts7x8/char2e.bmp @@ -0,0 +1,3 @@ +#define char2e_width 7 +#define char2e_height 8 +static char char2e_bits[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0}; diff --git a/src/fonts7x8/char2f.bmp b/src/fonts7x8/char2f.bmp new file mode 100755 index 0000000..f0eb75c --- /dev/null +++ b/src/fonts7x8/char2f.bmp @@ -0,0 +1,3 @@ +#define char2f_width 7 +#define char2f_height 8 +static char char2f_bits[] = {0x0, 0x4, 0x8, 0x10, 0x20, 0x40, 0x0, 0x0}; diff --git a/src/fonts7x8/char30.bmp b/src/fonts7x8/char30.bmp new file mode 100755 index 0000000..0e312f9 --- /dev/null +++ b/src/fonts7x8/char30.bmp @@ -0,0 +1,3 @@ +#define char30_width 7 +#define char30_height 8 +static char char30_bits[] = {0x38, 0x44, 0x4c, 0x54, 0x64, 0x44, 0x38, 0x0}; diff --git a/src/fonts7x8/char31.bmp b/src/fonts7x8/char31.bmp new file mode 100755 index 0000000..588ecb6 --- /dev/null +++ b/src/fonts7x8/char31.bmp @@ -0,0 +1,3 @@ +#define char31_width 7 +#define char31_height 8 +static char char31_bits[] = {0x10, 0x30, 0x10, 0x10, 0x10, 0x10, 0x38, 0x0}; diff --git a/src/fonts7x8/char32.bmp b/src/fonts7x8/char32.bmp new file mode 100755 index 0000000..0327870 --- /dev/null +++ b/src/fonts7x8/char32.bmp @@ -0,0 +1,3 @@ +#define char32_width 7 +#define char32_height 8 +static char char32_bits[] = {0x38, 0x44, 0x4, 0x18, 0x20, 0x40, 0x7c, 0x0}; diff --git a/src/fonts7x8/char33.bmp b/src/fonts7x8/char33.bmp new file mode 100755 index 0000000..1782692 --- /dev/null +++ b/src/fonts7x8/char33.bmp @@ -0,0 +1,3 @@ +#define char33_width 7 +#define char33_height 8 +static char char33_bits[] = {0x7c, 0x4, 0x8, 0x18, 0x4, 0x44, 0x38, 0x0}; diff --git a/src/fonts7x8/char34.bmp b/src/fonts7x8/char34.bmp new file mode 100755 index 0000000..cd3fcc7 --- /dev/null +++ b/src/fonts7x8/char34.bmp @@ -0,0 +1,3 @@ +#define char34_width 7 +#define char34_height 8 +static char char34_bits[] = {0x8, 0x18, 0x28, 0x48, 0x7c, 0x8, 0x8, 0x0}; diff --git a/src/fonts7x8/char35.bmp b/src/fonts7x8/char35.bmp new file mode 100755 index 0000000..03f68f9 --- /dev/null +++ b/src/fonts7x8/char35.bmp @@ -0,0 +1,3 @@ +#define char35_width 7 +#define char35_height 8 +static char char35_bits[] = {0x7c, 0x40, 0x78, 0x4, 0x4, 0x44, 0x38, 0x0}; diff --git a/src/fonts7x8/char36.bmp b/src/fonts7x8/char36.bmp new file mode 100755 index 0000000..5d21495 --- /dev/null +++ b/src/fonts7x8/char36.bmp @@ -0,0 +1,3 @@ +#define char36_width 7 +#define char36_height 8 +static char char36_bits[] = {0x1c, 0x20, 0x40, 0x78, 0x44, 0x44, 0x38, 0x0}; diff --git a/src/fonts7x8/char37.bmp b/src/fonts7x8/char37.bmp new file mode 100755 index 0000000..21b3d47 --- /dev/null +++ b/src/fonts7x8/char37.bmp @@ -0,0 +1,3 @@ +#define char37_width 7 +#define char37_height 8 +static char char37_bits[] = {0x7c, 0x4, 0x8, 0x10, 0x20, 0x20, 0x20, 0x0}; diff --git a/src/fonts7x8/char38.bmp b/src/fonts7x8/char38.bmp new file mode 100755 index 0000000..dd73095 --- /dev/null +++ b/src/fonts7x8/char38.bmp @@ -0,0 +1,3 @@ +#define char38_width 7 +#define char38_height 8 +static char char38_bits[] = {0x38, 0x44, 0x44, 0x38, 0x44, 0x44, 0x38, 0x0}; diff --git a/src/fonts7x8/char39.bmp b/src/fonts7x8/char39.bmp new file mode 100755 index 0000000..bccb8fc --- /dev/null +++ b/src/fonts7x8/char39.bmp @@ -0,0 +1,3 @@ +#define char39_width 7 +#define char39_height 8 +static char char39_bits[] = {0x38, 0x44, 0x44, 0x3c, 0x4, 0x8, 0x70, 0x0}; diff --git a/src/fonts7x8/char3a.bmp b/src/fonts7x8/char3a.bmp new file mode 100755 index 0000000..005a6f3 --- /dev/null +++ b/src/fonts7x8/char3a.bmp @@ -0,0 +1,3 @@ +#define char3a_width 7 +#define char3a_height 8 +static char char3a_bits[] = {0x0, 0x0, 0x10, 0x0, 0x10, 0x0, 0x0, 0x0}; diff --git a/src/fonts7x8/char3b.bmp b/src/fonts7x8/char3b.bmp new file mode 100755 index 0000000..cbd198c --- /dev/null +++ b/src/fonts7x8/char3b.bmp @@ -0,0 +1,3 @@ +#define char3b_width 7 +#define char3b_height 8 +static char char3b_bits[] = {0x0, 0x0, 0x10, 0x0, 0x10, 0x10, 0x20, 0x0}; diff --git a/src/fonts7x8/char3c.bmp b/src/fonts7x8/char3c.bmp new file mode 100755 index 0000000..ac4b443 --- /dev/null +++ b/src/fonts7x8/char3c.bmp @@ -0,0 +1,3 @@ +#define char3c_width 7 +#define char3c_height 8 +static char char3c_bits[] = {0x8, 0x10, 0x20, 0x40, 0x20, 0x10, 0x8, 0x0}; diff --git a/src/fonts7x8/char3d.bmp b/src/fonts7x8/char3d.bmp new file mode 100755 index 0000000..0883bce --- /dev/null +++ b/src/fonts7x8/char3d.bmp @@ -0,0 +1,3 @@ +#define char3d_width 7 +#define char3d_height 8 +static char char3d_bits[] = {0x0, 0x0, 0x7c, 0x0, 0x7c, 0x0, 0x0, 0x0}; diff --git a/src/fonts7x8/char3e.bmp b/src/fonts7x8/char3e.bmp new file mode 100755 index 0000000..c938bbf --- /dev/null +++ b/src/fonts7x8/char3e.bmp @@ -0,0 +1,3 @@ +#define char3e_width 7 +#define char3e_height 8 +static char char3e_bits[] = {0x20, 0x10, 0x8, 0x4, 0x8, 0x10, 0x20, 0x0}; diff --git a/src/fonts7x8/char3f.bmp b/src/fonts7x8/char3f.bmp new file mode 100755 index 0000000..214704c --- /dev/null +++ b/src/fonts7x8/char3f.bmp @@ -0,0 +1,3 @@ +#define char3f_width 7 +#define char3f_height 8 +static char char3f_bits[] = {0x38, 0x44, 0x8, 0x10, 0x10, 0x0, 0x10, 0x0}; diff --git a/src/fonts7x8/char40.bmp b/src/fonts7x8/char40.bmp new file mode 100755 index 0000000..d473a5c --- /dev/null +++ b/src/fonts7x8/char40.bmp @@ -0,0 +1,3 @@ +#define char40_width 7 +#define char40_height 8 +static char char40_bits[] = {0x20, 0x10, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0}; diff --git a/src/fonts7x8/char41.bmp b/src/fonts7x8/char41.bmp new file mode 100755 index 0000000..cc9d36e --- /dev/null +++ b/src/fonts7x8/char41.bmp @@ -0,0 +1,3 @@ +#define char41_width 7 +#define char41_height 8 +static char char41_bits[] = {0x0, 0x0, 0x38, 0x4, 0x3c, 0x44, 0x3c, 0x0}; diff --git a/src/fonts7x8/char42.bmp b/src/fonts7x8/char42.bmp new file mode 100755 index 0000000..6dab8b4 --- /dev/null +++ b/src/fonts7x8/char42.bmp @@ -0,0 +1,3 @@ +#define char42_width 7 +#define char42_height 8 +static char char42_bits[] = {0x40, 0x40, 0x78, 0x44, 0x44, 0x44, 0x78, 0x0}; diff --git a/src/fonts7x8/char43.bmp b/src/fonts7x8/char43.bmp new file mode 100755 index 0000000..42e9d24 --- /dev/null +++ b/src/fonts7x8/char43.bmp @@ -0,0 +1,3 @@ +#define char43_width 7 +#define char43_height 8 +static char char43_bits[] = {0x0, 0x0, 0x3c, 0x40, 0x40, 0x40, 0x3c, 0x0}; diff --git a/src/fonts7x8/char44.bmp b/src/fonts7x8/char44.bmp new file mode 100755 index 0000000..47854fa --- /dev/null +++ b/src/fonts7x8/char44.bmp @@ -0,0 +1,3 @@ +#define char44_width 7 +#define char44_height 8 +static char char44_bits[] = {0x4, 0x4, 0x3c, 0x44, 0x44, 0x44, 0x3c, 0x0}; diff --git a/src/fonts7x8/char45.bmp b/src/fonts7x8/char45.bmp new file mode 100755 index 0000000..f7c51dd --- /dev/null +++ b/src/fonts7x8/char45.bmp @@ -0,0 +1,3 @@ +#define char45_width 7 +#define char45_height 8 +static char char45_bits[] = {0x0, 0x0, 0x38, 0x44, 0x7c, 0x40, 0x3c, 0x0}; diff --git a/src/fonts7x8/char46.bmp b/src/fonts7x8/char46.bmp new file mode 100755 index 0000000..2564dad --- /dev/null +++ b/src/fonts7x8/char46.bmp @@ -0,0 +1,3 @@ +#define char46_width 7 +#define char46_height 8 +static char char46_bits[] = {0x18, 0x24, 0x20, 0x78, 0x20, 0x20, 0x20, 0x0}; diff --git a/src/fonts7x8/char47.bmp b/src/fonts7x8/char47.bmp new file mode 100755 index 0000000..69bad0a --- /dev/null +++ b/src/fonts7x8/char47.bmp @@ -0,0 +1,3 @@ +#define char47_width 7 +#define char47_height 8 +static char char47_bits[] = {0x0, 0x0, 0x38, 0x44, 0x44, 0x3c, 0x4, 0x38}; diff --git a/src/fonts7x8/char48.bmp b/src/fonts7x8/char48.bmp new file mode 100755 index 0000000..9b1a485 --- /dev/null +++ b/src/fonts7x8/char48.bmp @@ -0,0 +1,3 @@ +#define char48_width 7 +#define char48_height 8 +static char char48_bits[] = {0x40, 0x40, 0x78, 0x44, 0x44, 0x44, 0x44, 0x0}; diff --git a/src/fonts7x8/char49.bmp b/src/fonts7x8/char49.bmp new file mode 100755 index 0000000..c25b402 --- /dev/null +++ b/src/fonts7x8/char49.bmp @@ -0,0 +1,3 @@ +#define char49_width 7 +#define char49_height 8 +static char char49_bits[] = {0x10, 0x0, 0x30, 0x10, 0x10, 0x10, 0x38, 0x0}; diff --git a/src/fonts7x8/char4a.bmp b/src/fonts7x8/char4a.bmp new file mode 100755 index 0000000..8068f84 --- /dev/null +++ b/src/fonts7x8/char4a.bmp @@ -0,0 +1,3 @@ +#define char4a_width 7 +#define char4a_height 8 +static char char4a_bits[] = {0x8, 0x0, 0x38, 0x8, 0x8, 0x8, 0x48, 0x30}; diff --git a/src/fonts7x8/char4b.bmp b/src/fonts7x8/char4b.bmp new file mode 100755 index 0000000..ff16264 --- /dev/null +++ b/src/fonts7x8/char4b.bmp @@ -0,0 +1,3 @@ +#define char4b_width 7 +#define char4b_height 8 +static char char4b_bits[] = {0x40, 0x40, 0x44, 0x48, 0x70, 0x48, 0x44, 0x0}; diff --git a/src/fonts7x8/char4c.bmp b/src/fonts7x8/char4c.bmp new file mode 100755 index 0000000..4e83cb0 --- /dev/null +++ b/src/fonts7x8/char4c.bmp @@ -0,0 +1,3 @@ +#define char4c_width 7 +#define char4c_height 8 +static char char4c_bits[] = {0x30, 0x10, 0x10, 0x10, 0x10, 0x10, 0x38, 0x0}; diff --git a/src/fonts7x8/char4d.bmp b/src/fonts7x8/char4d.bmp new file mode 100755 index 0000000..3cdfbc2 --- /dev/null +++ b/src/fonts7x8/char4d.bmp @@ -0,0 +1,3 @@ +#define char4d_width 7 +#define char4d_height 8 +static char char4d_bits[] = {0x0, 0x0, 0x6c, 0x54, 0x54, 0x54, 0x44, 0x0}; diff --git a/src/fonts7x8/char4e.bmp b/src/fonts7x8/char4e.bmp new file mode 100755 index 0000000..d09b91d --- /dev/null +++ b/src/fonts7x8/char4e.bmp @@ -0,0 +1,3 @@ +#define char4e_width 7 +#define char4e_height 8 +static char char4e_bits[] = {0x0, 0x0, 0x78, 0x44, 0x44, 0x44, 0x44, 0x0}; diff --git a/src/fonts7x8/char4f.bmp b/src/fonts7x8/char4f.bmp new file mode 100755 index 0000000..25bcc4b --- /dev/null +++ b/src/fonts7x8/char4f.bmp @@ -0,0 +1,3 @@ +#define char4f_width 7 +#define char4f_height 8 +static char char4f_bits[] = {0x0, 0x0, 0x38, 0x44, 0x44, 0x44, 0x38, 0x0}; diff --git a/src/fonts7x8/char50.bmp b/src/fonts7x8/char50.bmp new file mode 100755 index 0000000..cce46c7 --- /dev/null +++ b/src/fonts7x8/char50.bmp @@ -0,0 +1,3 @@ +#define char50_width 7 +#define char50_height 8 +static char char50_bits[] = {0x0, 0x0, 0x78, 0x44, 0x44, 0x78, 0x40, 0x40}; diff --git a/src/fonts7x8/char51.bmp b/src/fonts7x8/char51.bmp new file mode 100755 index 0000000..bffbcd6 --- /dev/null +++ b/src/fonts7x8/char51.bmp @@ -0,0 +1,3 @@ +#define char51_width 7 +#define char51_height 8 +static char char51_bits[] = {0x0, 0x0, 0x3c, 0x44, 0x44, 0x3c, 0x4, 0x4}; diff --git a/src/fonts7x8/char52.bmp b/src/fonts7x8/char52.bmp new file mode 100755 index 0000000..ab99578 --- /dev/null +++ b/src/fonts7x8/char52.bmp @@ -0,0 +1,3 @@ +#define char52_width 7 +#define char52_height 8 +static char char52_bits[] = {0x0, 0x0, 0x5c, 0x60, 0x40, 0x40, 0x40, 0x0}; diff --git a/src/fonts7x8/char53.bmp b/src/fonts7x8/char53.bmp new file mode 100755 index 0000000..e1064a4 --- /dev/null +++ b/src/fonts7x8/char53.bmp @@ -0,0 +1,3 @@ +#define char53_width 7 +#define char53_height 8 +static char char53_bits[] = {0x0, 0x0, 0x3c, 0x40, 0x38, 0x4, 0x78, 0x0}; diff --git a/src/fonts7x8/char54.bmp b/src/fonts7x8/char54.bmp new file mode 100755 index 0000000..39c7bc8 --- /dev/null +++ b/src/fonts7x8/char54.bmp @@ -0,0 +1,3 @@ +#define char54_width 7 +#define char54_height 8 +static char char54_bits[] = {0x20, 0x20, 0x78, 0x20, 0x20, 0x24, 0x18, 0x0}; diff --git a/src/fonts7x8/char55.bmp b/src/fonts7x8/char55.bmp new file mode 100755 index 0000000..26b4c87 --- /dev/null +++ b/src/fonts7x8/char55.bmp @@ -0,0 +1,3 @@ +#define char55_width 7 +#define char55_height 8 +static char char55_bits[] = {0x0, 0x0, 0x44, 0x44, 0x44, 0x4c, 0x34, 0x0}; diff --git a/src/fonts7x8/char56.bmp b/src/fonts7x8/char56.bmp new file mode 100755 index 0000000..0f51a42 --- /dev/null +++ b/src/fonts7x8/char56.bmp @@ -0,0 +1,3 @@ +#define char56_width 7 +#define char56_height 8 +static char char56_bits[] = {0x0, 0x0, 0x44, 0x44, 0x44, 0x28, 0x10, 0x0}; diff --git a/src/fonts7x8/char57.bmp b/src/fonts7x8/char57.bmp new file mode 100755 index 0000000..b469154 --- /dev/null +++ b/src/fonts7x8/char57.bmp @@ -0,0 +1,3 @@ +#define char57_width 7 +#define char57_height 8 +static char char57_bits[] = {0x0, 0x0, 0x44, 0x44, 0x54, 0x54, 0x6c, 0x0}; diff --git a/src/fonts7x8/char58.bmp b/src/fonts7x8/char58.bmp new file mode 100755 index 0000000..73c281d --- /dev/null +++ b/src/fonts7x8/char58.bmp @@ -0,0 +1,3 @@ +#define char58_width 7 +#define char58_height 8 +static char char58_bits[] = {0x0, 0x0, 0x44, 0x28, 0x10, 0x28, 0x44, 0x0}; diff --git a/src/fonts7x8/char59.bmp b/src/fonts7x8/char59.bmp new file mode 100755 index 0000000..804a574 --- /dev/null +++ b/src/fonts7x8/char59.bmp @@ -0,0 +1,3 @@ +#define char59_width 7 +#define char59_height 8 +static char char59_bits[] = {0x0, 0x0, 0x44, 0x44, 0x44, 0x3c, 0x4, 0x38}; diff --git a/src/fonts7x8/char5a.bmp b/src/fonts7x8/char5a.bmp new file mode 100755 index 0000000..1815337 --- /dev/null +++ b/src/fonts7x8/char5a.bmp @@ -0,0 +1,3 @@ +#define char5a_width 7 +#define char5a_height 8 +static char char5a_bits[] = {0x0, 0x0, 0x7c, 0x8, 0x10, 0x20, 0x7c, 0x0}; diff --git a/src/fonts7x8/char5b.bmp b/src/fonts7x8/char5b.bmp new file mode 100755 index 0000000..7103fcd --- /dev/null +++ b/src/fonts7x8/char5b.bmp @@ -0,0 +1,3 @@ +#define char5b_width 7 +#define char5b_height 8 +static char char5b_bits[] = {0x1c, 0x30, 0x30, 0x60, 0x30, 0x30, 0x1c, 0x0}; diff --git a/src/fonts7x8/char5c.bmp b/src/fonts7x8/char5c.bmp new file mode 100755 index 0000000..fa4894a --- /dev/null +++ b/src/fonts7x8/char5c.bmp @@ -0,0 +1,3 @@ +#define char5c_width 7 +#define char5c_height 8 +static char char5c_bits[] = {0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10}; diff --git a/src/fonts7x8/char5d.bmp b/src/fonts7x8/char5d.bmp new file mode 100755 index 0000000..2d48d04 --- /dev/null +++ b/src/fonts7x8/char5d.bmp @@ -0,0 +1,3 @@ +#define char5d_width 7 +#define char5d_height 8 +static char char5d_bits[] = {0x70, 0x18, 0x18, 0xc, 0x18, 0x18, 0x70, 0x0}; diff --git a/src/fonts7x8/char5e.bmp b/src/fonts7x8/char5e.bmp new file mode 100755 index 0000000..e4a71dd --- /dev/null +++ b/src/fonts7x8/char5e.bmp @@ -0,0 +1,3 @@ +#define char5e_width 7 +#define char5e_height 8 +static char char5e_bits[] = {0x30, 0x54, 0x18, 0x0, 0x0, 0x0, 0x0, 0x0}; diff --git a/src/fonts7x8/char5f.bmp b/src/fonts7x8/char5f.bmp new file mode 100755 index 0000000..b406f32 --- /dev/null +++ b/src/fonts7x8/char5f.bmp @@ -0,0 +1,3 @@ +#define char5f_width 7 +#define char5f_height 8 +static char char5f_bits[] = {0x0, 0x54, 0x28, 0x54, 0x28, 0x54, 0x0, 0x0}; diff --git a/src/fonts7x8/lowres.bmp b/src/fonts7x8/lowres.bmp new file mode 100755 index 0000000..11b5a17 --- /dev/null +++ b/src/fonts7x8/lowres.bmp @@ -0,0 +1,3 @@ +#define lowres_width 14 +#define lowres_height 16 +static unsigned char lowres_bits[] = {0xff, 0xfc, 0xff, 0xfc, 0xff, 0xfc, 0xff, 0xfc, 0xff, 0xfc, 0xff, 0xfc, 0xff, 0xfc, 0xff, 0xfc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; diff --git a/src/iou.h b/src/iou.h new file mode 100755 index 0000000..5918478 --- /dev/null +++ b/src/iou.h @@ -0,0 +1,111 @@ +#define KEYBOARD 0xC000 +#define CLR80STORE 0xC000 +#define SET80STORE 0xC001 +#define RDMAINRAM 0xC002 +#define RDCARDRAM 0xC003 +#define WRMAINRAM 0xC004 +#define WRCARDRAM 0xC005 +#define SETSLOTCXROM 0xC006 +#define SETINTCXROM 0xC007 +#define SETSTDZP 0xC008 +#define SETALTZP 0xC009 +#define SETINTC3ROM 0xC00A +#define SETSLOTC3ROM 0xC00B +#define CLR80VID 0xC00C +#define SET80VID 0xC00D +#define CLRALTCHAR 0xC00E +#define SETALTCHAR 0xC00F + +#define KBDSTRB 0xC010 +#define RDLCBNK2 0xC011 +#define RDLCRAM 0xC012 +#define RDRAMRD 0xC013 +#define RDRAMWRT 0xC014 +#define RDCXROM 0xC015 +#define RDALTZP 0xC016 +#define RDC3ROM 0xC017 +#define RD80STORE 0xC018 +#define RDVBLBAR 0xC019 +#define RDTEXT 0xC01A +#define RDMIXED 0xC01B +#define RDPAGE2 0xC01C +#define RDHIRES 0xC01D +#define RDALTCHAR 0xC01E +#define RD80COL 0xC01F + +#define TAPEOUT 0xC020 +#define PRNTOUT 0xC021 /* Virtual printer */ +#define SPKR 0xC030 + +#define TXTCLR 0xC050 +#define TXTSET 0xC051 +#define MIXCLR 0xC052 +#define MIXSET 0xC053 +#define LOWSCR 0xC054 +#define HISCR 0xC055 +#define LOWRES 0xC056 +#define HIRES 0xC057 +#define CLRAN0 0xC058 +#define SETAN0 0xC059 +#define CLRAN1 0xC05A +#define SETAN1 0xC05B +#define CLRAN2 0xC05C +#define SETAN2 0xC05D +#define CLRAN3 0xC05E +#define SETDHIRES 0xC05E +#define SETAN3 0xC05F +#define CLRDHIRES 0xC05F + +#define TAPEIN 0xC060 +#define BUTN0 0xC061 +#define BUTN1 0xC062 +#define BUTN2 0xC063 +#define PADDL0 0xC064 +#define PADDL1 0xC065 +#define PADDL2 0xC066 +#define PADDL3 0xC067 + +#define BTNDURATION 0x10 +#define PDLDURATION 0x10 + +#define PTRIG 0xC070 +#define SETIOUDIS 0xC07E +#define RDIOUDIS 0xC07E +#define CLRIOUDIS 0xC07F +#define RDDHIRES 0xC07F + +#define CLRROM 0xCFFF + +/* Memory soft switches */ +#define SS_SLOTCXROM (1<<1) +#define SS_SLOTC3ROM (1<<2) +#define SS_EXPNROM (1<<3) /* 80 column ROM $C800-$CFFF active */ +#define SS_RAMRD (1<<4) +#define SS_RAMWRT (1<<5) +#define SS_LCRAMMAP (1<<6) +#define SS_LCBNK2 (1<<7) +#define SS_LCRAMWRT (1<<8) + +/* Video soft switched */ +#define SS_TEXT (1<<0) +#define SS_MIXED (1<<1) +#define SS_PAGE2 (1<<2) +#define SS_HIRES (1<<3) +#define SS_VBLBAR (1<<4) +#define SS_80STORE (1<<5) +#define SS_80VID (1<<6) +#define SS_ALTZIP (1<<7) + +#define SS_AN0 (1<<1) +#define SS_AN1 (1<<2) +#define SS_AN2 (1<<3) +#define SS_AN3 (1<<4) + +#define SS_SET(iou, ss) iou |= (ss) +#define SS_RESET(iou, ss) iou &= ~(ss) +#define SS_ISSET(iou, ss) (iou & (ss)) +#define IO_PAGE(a) ((a)&0xFF) +#define IO_SLOT(a) (((a)>>4)&0x0F) +#define IO_OFFSET(a) ((a)&0x0F) +extern UInt16 memIOU, vidIOU, kbdIOU, spkrIOU, btnIOU[3], pdlIOU[2], pdlResetIOU[2]; + diff --git a/src/memio.c b/src/memio.c new file mode 100755 index 0000000..0545ad4 --- /dev/null +++ b/src/memio.c @@ -0,0 +1,1802 @@ +#include +#include "Apple2.h" +extern UInt16 grMode; + +UInt16 memIOU, vidIOU, kbdIOU, spkrIOU, btnIOU[3], pdlIOU[2], pdlResetIOU[2]; +UInt8 kbdBuffer[16]; +UInt8 kbdHead, kbdCount; +UInt8 *AppleMemory; +UInt8 *AuxMemory; +UInt8 *AppleROM; +UInt8 *BootROM; +READBYTE *ReadFunction; +WRITEBYTE *WriteFunction; +UInt8 auxDirty = 0; + +void showDiskName(UInt16, Char *); +void showDriveState(UInt16, Boolean); +UInt8 RIOM(UInt16); +void WIOM(UInt16, UInt8); +UInt8 RC3M(UInt16); +void clrVidFuncs(UInt16); +void toggleVideoSoftSwitch(UInt8); + +/* + * Function prototypes for sector nibblizing + */ +static void init_GCR_table(void); +static UInt8 gcr_read_nibble(void); +static void gcr_write_nibble( UInt8 ); +static void decode62( UInt8* ); +static void encode62( UInt8* ); +static void FM_encode( UInt8 ); +static UInt8 FM_decode(void); +static void write_sync( int ); +static int read_address_field( int*, int*, int* ); +static void write_address_field( int, int, int ); +static int read_data_field(void); +static void write_data_field(void); +int NibblesToSectors(UInt8 *nibbles, UInt8 *sectors, int volume, int track); +void SectorsToNibbles(UInt8 *sectors, UInt8 *nibbles, int volume, int track); + +void initMemory(void) +{ + vidIOU = SS_TEXT; + memIOU = + kbdIOU = + spkrIOU = + btnIOU[0] = + btnIOU[1] = + btnIOU[2] = + pdlIOU[0] = + pdlIOU[1] = 0; + pdlResetIOU[0] = + pdlResetIOU[1] = 0x80; + kbdHead = + kbdCount = 0; + MemSet(AppleMemory, 65536, 0); + MemSet(AuxMemory, 16384+2048, 0); + MemSet(ReadFunction, 1024, 0); + MemSet(WriteFunction, 1024, 0); + loadROM(); + MemMove(AppleMemory + 0xC100, AppleROM, 0x3F00); + setMemFuncs(); +} + +/*****************************************************************************\ +* * +* ROM Access * +* * +\*****************************************************************************/ + +/* Apple ROM Paging */ + +void READONLY(UInt16, UInt8); +UInt8 RRMP(UInt16); +void awrap_ROMReadWrite(void) +{ + asm(".global RRMP"); + asm(".global READONLY"); + asm("RRMP:"); + asm("clr.l %d0"); + asm("READONLY:"); + asm("rts"); +} +RDMEM_CWRAP(REXP, address) +{ + if (!SS_ISSET(memIOU, SS_SLOTCXROM) && address == 0xCFFF) + { + MemMove(AppleMemory + 0xCE00, BootROM, 256); + SS_RESET(memIOU, SS_EXPNROM); + return (0x00); + } + else + { + return (AppleMemory[address]); + } +} +RDMEM_CWRAP(RC3M, address) +{ + if (!SS_ISSET(memIOU, SS_SLOTC3ROM)) + { + SS_SET(memIOU, SS_EXPNROM); + MemMove(AppleMemory + 0xC800, AppleROM + 0x700, 2048); + } + return (AppleMemory[address]); +} +void loadROM(void) +{ + DmOpenRef romDB; + LocalID romID; + MemHandle romRec; + UInt8 *roms; + UInt32 romStart; + UInt16 count; + + romID = DmFindDatabase(0, "apple2e.rom"); + romDB = DmOpenDatabase(0, romID, dmModeReadOnly); + romRec = DmQueryRecord(romDB, 0); + roms = (UInt8 *) MemHandleLock(romRec); + romStart = 0x004100; + AppleROM = MemPtrNew(0x3F00); + MemMove(AppleROM, roms + romStart, 0x3F00); + MemHandleUnlock(romRec); + DmCloseDatabase(romDB); + romID = DmFindDatabase(0, "slot6.rom"); + romDB = DmOpenDatabase(0, romID, dmModeReadOnly); + romRec = DmQueryRecord(romDB, 0); + roms = (UInt8 *) MemHandleLock(romRec); + BootROM = MemPtrNew(256); + MemMove(BootROM, roms, 256); + MemHandleUnlock(romRec); + DmCloseDatabase(romDB); + BootROM[0x004C] = 0xA9; + BootROM[0x004D] = 0x00; + BootROM[0x004E] = 0xEA; +} +void unloadROM(void) +{ + MemPtrFree(AppleROM); + MemPtrFree(BootROM); +} + +/*****************************************************************************\ +* * +* Soft switches * +* * +\*****************************************************************************/ + +void AuxWriteBnk1(UInt16, UInt8); +void AuxWriteBnk2(UInt16, UInt8); +void AuxWrite(UInt16, UInt8); +void AuxMapWriteBnk1(UInt16, UInt8); +void AuxMapWriteBnk2(UInt16, UInt8); +void AuxMapWrite(UInt16, UInt8); +UInt8 AuxReadBnk1(UInt16); +UInt8 AuxReadBnk2(UInt16); +UInt8 AuxRead(UInt16); +UInt8 RomRead(UInt16); +void awrap_AuxMemReadWrite(void) +{ + asm(".global AuxWriteBnk1"); + asm(".global AuxWriteBnk2"); + asm(".global AuxWrite"); + asm(".global AuxMapWriteBnk1"); + asm(".global AuxMapWriteBnk2"); + asm(".global AuxMapWrite"); + asm(".global AuxReadBnk1"); + asm(".global AuxReadBnk2"); + asm(".global AuxRead"); + asm(".global RomRead"); + asm("AuxWriteBnk1:"); + asm("move.l AuxMemory@END.w(%a5), %a6"); + asm("sub.l #0xD000, %a6"); + asm("move.b %d0, (%a6, %d6.l)"); + asm("rts"); + asm("AuxWriteBnk2:"); + asm("AuxWrite:"); + asm("move.l AuxMemory@END.w(%a5), %a6"); + asm("sub.l #0xC000, %a6"); + asm("move.b %d0, (%a6, %d6.l)"); + asm("rts"); + asm("AuxMapWriteBnk1:"); + asm("move.l AuxMemory@END.w(%a5), %a6"); + asm("sub.l #0xD000, %a6"); + asm("move.b %d0, (%a6, %d6.l)"); + asm("move.b %d0, (%a2, %d6.l)"); + asm("rts"); + asm("AuxMapWriteBnk2:"); + asm("AuxMapWrite:"); + asm("move.l AuxMemory@END.w(%a5), %a6"); + asm("sub.l #0xC000, %a6"); + asm("move.b %d0, (%a6, %d6.l)"); + asm("move.b %d0, (%a2, %d6.l)"); + asm("rts"); + asm("AuxReadBnk1:"); + asm("move.l AuxMemory@END.w(%a5), %a6"); + asm("sub.l #0xD000, %a6"); + asm("clr.l %d0"); + asm("move.b (%a6, %d6.l), %d0"); + asm("rts"); + asm("AuxReadBnk2:"); + asm("AuxRead:"); + asm("move.l AuxMemory@END.w(%a5), %a6"); + asm("sub.l #0xC000, %a6"); + asm("clr.l %d0"); + asm("move.b (%a6, %d6.l), %d0"); + asm("rts"); + asm("RomRead:"); + asm("move.l AppleROM@END.w(%a5), %a6"); + asm("sub.l #0xC100, %a6"); + asm("clr.l %d0"); + asm("move.b (%a6, %d6.l), %d0"); + asm("rts"); +} +void WTXTM(UInt16, UInt8); +void WATXTM(UInt16, UInt8); +UInt8 RATXTM(UInt16 address); +void writeMemorySoftSwitch(UInt8 io) +{ + UInt16 page; + UInt8 *tempPage; + + switch (io) + { + case IO_OFFSET(CLR80STORE): + if (SS_ISSET(vidIOU, SS_80STORE)) + { + clrVidFuncs(vidIOU); + SS_RESET(vidIOU, SS_80STORE); + if (SS_ISSET(vidIOU, SS_PAGE2)) + { + WriteFunction[0x08] = WTXTM; + WriteFunction[0x09] = WTXTM; + WriteFunction[0x0A] = WTXTM; + WriteFunction[0x0B] = WTXTM; + } + else + { + WriteFunction[0x04] = WTXTM; + WriteFunction[0x05] = WTXTM; + WriteFunction[0x06] = WTXTM; + WriteFunction[0x07] = WTXTM; + } + } + break; + case IO_OFFSET(SET80STORE): + if (!SS_ISSET(vidIOU, SS_80STORE)) + { + clrVidFuncs(vidIOU); + SS_SET(vidIOU, SS_80STORE); + if (SS_ISSET(vidIOU, SS_PAGE2)) + { + if ((grMode > GRMODE_COLOR) && prefs.enable80Col) + { + WriteFunction[0x04] = WATXTM; + WriteFunction[0x05] = WATXTM; + WriteFunction[0x06] = WATXTM; + WriteFunction[0x07] = WATXTM; + ReadFunction[0x04] = RATXTM; + ReadFunction[0x05] = RATXTM; + ReadFunction[0x06] = RATXTM; + ReadFunction[0x07] = RATXTM; + } + else + { + WriteFunction[0x04] = READONLY; + WriteFunction[0x05] = READONLY; + WriteFunction[0x06] = READONLY; + WriteFunction[0x07] = READONLY; + } + } + else + { + WriteFunction[0x04] = WTXTM; + WriteFunction[0x05] = WTXTM; + WriteFunction[0x06] = WTXTM; + WriteFunction[0x07] = WTXTM; + } + } + break; + case IO_OFFSET(RDMAINRAM): + if (SS_ISSET(memIOU, SS_RAMRD)) + { + SS_RESET(memIOU, SS_RAMRD); + for (page = 0x02; page < 0xC0; page++) + ReadFunction[page] = NULL; + setVideoFuncs(false); + } + break; + case IO_OFFSET(RDCARDRAM): + if (!SS_ISSET(memIOU, SS_RAMRD)) + { + SS_SET(memIOU, SS_RAMRD); + for (page = 0x02; page < 0xC0; page++) + ReadFunction[page] = RRMP; + } + break; + case IO_OFFSET(WRMAINRAM): + if (SS_ISSET(memIOU, SS_RAMWRT)) + { + SS_RESET(memIOU, SS_RAMWRT); + for (page = 0x02; page < 0xC0; page++) + WriteFunction[page] = NULL; + setVideoFuncs(false); + } + break; + case IO_OFFSET(WRCARDRAM): + if (!SS_ISSET(memIOU, SS_RAMWRT)) + { + SS_SET(memIOU, SS_RAMWRT); + for (page = 0x02; page < 0xC0; page++) + WriteFunction[page] = READONLY; + } + break; + case IO_OFFSET(SETSLOTCXROM): + if (SS_ISSET(memIOU, SS_SLOTCXROM)) + { + SS_RESET(memIOU, SS_SLOTCXROM); + ReadFunction[0xC1] = RRMP; + ReadFunction[0xC2] = RRMP; + ReadFunction[0xC4] = RRMP; + ReadFunction[0xC5] = RRMP; + ReadFunction[0xC6] = RRMP; + ReadFunction[0xC7] = RRMP; + MemSet(AppleMemory + 0xC100, 512, 0); + MemSet(AppleMemory + 0xC400, 1024, 0); + ReadFunction[0xC6] = NULL; + MemMove(AppleMemory + 0x00C600, BootROM, 256); + } + break; + case IO_OFFSET(SETINTCXROM): + if (!SS_ISSET(memIOU, SS_SLOTCXROM)) + { + SS_SET(memIOU, SS_SLOTCXROM); + ReadFunction[0xC1] = NULL; + ReadFunction[0xC2] = NULL; + ReadFunction[0xC4] = NULL; + ReadFunction[0xC5] = NULL; + ReadFunction[0xC6] = NULL; + ReadFunction[0xC7] = NULL; + MemMove(AppleMemory + 0xC100, AppleROM, 512); + MemMove(AppleMemory + 0xC400, AppleROM + 0x300, 1024); + } + break; + case IO_OFFSET(SETINTC3ROM): + if (!SS_ISSET(memIOU, SS_SLOTC3ROM)) + { + SS_SET(memIOU, SS_SLOTC3ROM); + MemMove(AppleMemory + 0xC300, AppleROM + 0x200, 256); + } + break; + case IO_OFFSET(SETSLOTC3ROM): + if (SS_ISSET(memIOU, SS_SLOTC3ROM)) + { + SS_RESET(memIOU, SS_SLOTC3ROM); + MemSet(AppleMemory + 0xC300, 256, 0); + } + break; + case IO_OFFSET(CLR80VID): + SS_RESET(vidIOU, SS_80VID); + setVideoFuncs(true); + break; + case IO_OFFSET(SET80VID): + SS_SET(vidIOU, SS_80VID); + setVideoFuncs(true); + break; + } +} +void updateLanguageCardMapping(void) +{ + READBYTE rfn; + WRITEBYTE wfn; + UInt16 page; + + if (SS_ISSET(memIOU, SS_LCRAMMAP)) + { + MemMove(AppleMemory + 0xD000, AuxMemory + (SS_ISSET(memIOU, SS_LCBNK2) ? 0x1000 : 0x0000), 4096); + MemMove(AppleMemory + 0xE000, AuxMemory + 0x2000, 8192); + } + else + { + MemMove(AppleMemory + 0xD000, AppleROM + 0xD000 - 0xC100, 4096+8192); + } + if (SS_ISSET(memIOU, SS_LCRAMWRT)) + { + if (SS_ISSET(memIOU, SS_LCRAMMAP)) + { + wfn = SS_ISSET(memIOU, SS_LCBNK2) ? AuxMapWriteBnk2 : AuxMapWriteBnk1; + WriteFunction[0xD0] = WriteFunction[0xD1] = wfn; + WriteFunction[0xD2] = WriteFunction[0xD3] = wfn; + WriteFunction[0xD4] = WriteFunction[0xD5] = wfn; + WriteFunction[0xD6] = WriteFunction[0xD7] = wfn; + WriteFunction[0xD8] = WriteFunction[0xD9] = wfn; + WriteFunction[0xDA] = WriteFunction[0xDB] = wfn; + WriteFunction[0xDC] = WriteFunction[0xDD] = wfn; + WriteFunction[0xDE] = WriteFunction[0xDF] = wfn; + for (page = 0xE0; page <= 0xFF; page++) + WriteFunction[page] = AuxMapWrite; + } + else + { + wfn = SS_ISSET(memIOU, SS_LCBNK2) ? AuxWriteBnk2 : AuxWriteBnk1; + WriteFunction[0xD0] = WriteFunction[0xD1] = wfn; + WriteFunction[0xD2] = WriteFunction[0xD3] = wfn; + WriteFunction[0xD4] = WriteFunction[0xD5] = wfn; + WriteFunction[0xD6] = WriteFunction[0xD7] = wfn; + WriteFunction[0xD8] = WriteFunction[0xD9] = wfn; + WriteFunction[0xDA] = WriteFunction[0xDB] = wfn; + WriteFunction[0xDC] = WriteFunction[0xDD] = wfn; + WriteFunction[0xDE] = WriteFunction[0xDF] = wfn; + for (page = 0xE0; page <= 0xFF; page++) + WriteFunction[page] = AuxWrite; + } + } + else + for (page = 0xD0; page <= 0xFF; page++) + WriteFunction[page] = READONLY; + for (page = 0xD0; page <= 0xFF; page++) + ReadFunction[page] = NULL; + clrPcCheckFuncs(); + auxDirty = 0; +} +void toggleLanguageCard(UInt8 io) +{ + READBYTE rfn; + WRITEBYTE wfn; + UInt16 page, dirty, pc6502; + + /* set IOU soft switches */ + dirty = memIOU; + switch (io) + { + case 0x00: + case 0x04: + SS_SET(memIOU, SS_LCBNK2); + SS_SET(memIOU, SS_LCRAMMAP); + SS_RESET(memIOU, SS_LCRAMWRT); + break; + case 0x01: + case 0x05: + SS_SET(memIOU, SS_LCBNK2); + SS_RESET(memIOU, SS_LCRAMMAP); + SS_SET(memIOU, SS_LCRAMWRT); + break; + case 0x02: + case 0x06: + SS_SET(memIOU, SS_LCBNK2); + SS_RESET(memIOU, SS_LCRAMMAP); + SS_RESET(memIOU, SS_LCRAMWRT); + break; + case 0x03: + case 0x07: + SS_SET(memIOU, SS_LCBNK2); + SS_SET(memIOU, SS_LCRAMMAP); + SS_SET(memIOU, SS_LCRAMWRT); + break; + case 0x08: + case 0x0C: + SS_RESET(memIOU, SS_LCBNK2); + SS_SET(memIOU, SS_LCRAMMAP); + SS_RESET(memIOU, SS_LCRAMWRT); + break; + case 0x09: + case 0x0D: + SS_RESET(memIOU, SS_LCBNK2); + SS_RESET(memIOU, SS_LCRAMMAP); + SS_SET(memIOU, SS_LCRAMWRT); + break; + case 0x0A: + case 0x0E: + SS_RESET(memIOU, SS_LCBNK2); + SS_RESET(memIOU, SS_LCRAMMAP); + SS_RESET(memIOU, SS_LCRAMWRT); + break; + case 0x0B: + case 0x0F: + SS_RESET(memIOU, SS_LCBNK2); + SS_SET(memIOU, SS_LCRAMMAP); + SS_SET(memIOU, SS_LCRAMWRT); + break; + } + /* + * Update only the changed state. + */ + if ((dirty ^= memIOU)) + { + if (dirty & SS_LCRAMMAP) + { + updateLanguageCardMapping(); + } + else + { + if (SS_ISSET(memIOU, SS_LCRAMMAP)) + { + if (dirty & SS_LCBNK2) + { + pc6502 = state6502.LongRegs.PC-state6502.LongRegs.MEMBASE; + if ((pc6502 >= 0xD000) && (pc6502 < 0xE000)) + { + updateLanguageCardMapping(); + return; + } + if (!auxDirty) + { + /* + * Install special versions of JMP, JSR, BRK, RTI, and RTS that check for memory ranges. + */ + setPcCheckFuncs(); + auxDirty = 1; + } + rfn = SS_ISSET(memIOU, SS_LCBNK2) ? AuxReadBnk2 : AuxReadBnk1; + ReadFunction[0xD0] = ReadFunction[0xD1] = rfn; + ReadFunction[0xD2] = ReadFunction[0xD3] = rfn; + ReadFunction[0xD4] = ReadFunction[0xD5] = rfn; + ReadFunction[0xD6] = ReadFunction[0xD7] = rfn; + ReadFunction[0xD8] = ReadFunction[0xD9] = rfn; + ReadFunction[0xDA] = ReadFunction[0xDB] = rfn; + ReadFunction[0xDC] = ReadFunction[0xDD] = rfn; + ReadFunction[0xDE] = ReadFunction[0xDF] = rfn; + } + if (SS_ISSET(memIOU, SS_LCRAMWRT)) + { + wfn = SS_ISSET(memIOU, SS_LCBNK2) ? AuxMapWriteBnk2 : AuxMapWriteBnk1; + WriteFunction[0xD0] = WriteFunction[0xD1] = wfn; + WriteFunction[0xD2] = WriteFunction[0xD3] = wfn; + WriteFunction[0xD4] = WriteFunction[0xD5] = wfn; + WriteFunction[0xD6] = WriteFunction[0xD7] = wfn; + WriteFunction[0xD8] = WriteFunction[0xD9] = wfn; + WriteFunction[0xDA] = WriteFunction[0xDB] = wfn; + WriteFunction[0xDC] = WriteFunction[0xDD] = wfn; + WriteFunction[0xDE] = WriteFunction[0xDF] = wfn; + if (dirty & SS_LCRAMWRT) + for (page = 0xE0; page <= 0xFF; page++) + WriteFunction[page] = AuxMapWrite; + } + else if (dirty & SS_LCRAMWRT) + for (page = 0xD0; page <= 0xFF; page++) + WriteFunction[page] = READONLY; + } + else + { + if (SS_ISSET(memIOU, SS_LCRAMWRT)) + { + wfn = SS_ISSET(memIOU, SS_LCBNK2) ? AuxWriteBnk2 : AuxWriteBnk1; + WriteFunction[0xD0] = WriteFunction[0xD1] = wfn; + WriteFunction[0xD2] = WriteFunction[0xD3] = wfn; + WriteFunction[0xD4] = WriteFunction[0xD5] = wfn; + WriteFunction[0xD6] = WriteFunction[0xD7] = wfn; + WriteFunction[0xD8] = WriteFunction[0xD9] = wfn; + WriteFunction[0xDA] = WriteFunction[0xDB] = wfn; + WriteFunction[0xDC] = WriteFunction[0xDD] = wfn; + WriteFunction[0xDE] = WriteFunction[0xDF] = wfn; + if (dirty & SS_LCRAMWRT) + for (page = 0xE0; page <= 0xFF; page++) + WriteFunction[page] = AuxWrite; + } + else if (dirty & SS_LCRAMWRT) + for (page = 0xD0; page <= 0xFF; page++) + WriteFunction[page] = READONLY; + } + } + } +} +void setMemFuncs(void) +{ + UInt16 page; + + updateLanguageCardMapping(); + if (!SS_ISSET(memIOU, SS_SLOTCXROM)) + { + ReadFunction[0xC1] = RRMP; + ReadFunction[0xC2] = RRMP; + ReadFunction[0xC4] = RRMP; + ReadFunction[0xC5] = RRMP; + ReadFunction[0xC6] = RRMP; + ReadFunction[0xC7] = RRMP; + } + if (SS_ISSET(memIOU, SS_RAMRD)) + for (page = 0x02; page < 0xC0; page++) + ReadFunction[page] = RRMP; + if (SS_ISSET(memIOU, SS_RAMWRT)) + for (page = 0x02; page < 0xC0; page++) + WriteFunction[page] = READONLY; + ReadFunction[0xC0] = RIOM; + ReadFunction[0xC3] = RC3M; + WriteFunction[0xC0] = WIOM; +} + +/*****************************************************************************\ +* * +* Disk access control * +* * +\*****************************************************************************/ + +#define RAW_TRACK_BYTES 6192 +#define RAW_SECTOR_BYTES 387 +#define DOS_TRACK_BYTES 4096 +#define RAW_TRACK_BITS (RAW_TRACK_BYTES*8) +#define NO_OF_PHASES 8 +#define MAX_PHYSICAL_TRACK_NO (40*NO_OF_PHASES) +#define MAX_DRIVE_NO 2 + +static Int8 stepper_movement_table[16][NO_OF_PHASES] = +{ + { 0, 0, 0, 0, 0, 0, 0, 0}, /* all electromagnets off */ + { 0, -1, -2, -3, 0, 3, 2, 1}, /* EM 1 on */ + { 2, 1, 0, -1, -2, -3, 0, 3}, /* EM 2 on */ + { 1, 0, -1, -2, -3, 0, 3, 2}, /* EMs 1 & 2 on */ + { 0, 3, 2, 1, 0, -1, -2, -3}, /* EM 3 on */ + { 0, -1, 0, 1, 0, -1, 0, 1}, /* EMs 1 & 3 on */ + { 3, 2, 1, 0, -1, -2, -3, 0}, /* EMs 2 & 3 on */ + { 2, 1, 0, -1, -2, -3, 0, 3}, /* EMs 1, 2 & 3 on */ + {-2, -3, 0, 3, 2, 1, 0, -1}, /* EM 4 on */ + {-1, -2, -3, 0, 3, 2, 1, 0}, /* EMs 1 & 4 on */ + { 0, 1, 0, -1, 0, 1, 0, -1}, /* EMs 2 & 4 */ + { 0, -1, -2, -3, 0, 3, 2, 1}, /* EMs 1, 2 & 4 on */ + {-3, 0, 3, 2, 1, 0, -1, -2}, /* EMs 3 & 4 on */ + {-2, -3, 0, 3, 2, 1, 0, -1}, /* EMs 1, 3 & 4 on */ + { 0, 3, 2, 1, 0, -1, -2, -3}, /* EMs 2, 3 & 4 on */ + { 0, 0, 0, 0, 0, 0, 0, 0} +}; /* all electromagnets on */ + +static Boolean track_buffer_valid; +static Int8 write_mode; +static UInt8 *nibble_buf; +static UInt16 track_buffer_pos; +static UInt16 track_buffer_size; +static UInt8 write_protect; +static UInt8 address_latch, data_latch; +static Boolean motor_state; +static UInt8 drive_no = 0; +struct stateDisk_t +{ + char diskname[32]; + LocalID diskdb; + DmOpenRef diskimage; + MemHandle track_buffer_handle; + Int16 physical_track_no; + Int16 stepper_status; + Boolean track_buffer_valid; + Boolean track_buffer_raw; + Boolean track_buffer_dirty; + Int8 track_count; + Int8 track_buffer_track; + Int8 write_mode; + Int16 last_track; + UInt8 *nibble_buf; + UInt16 track_buffer_pos; + UInt16 track_buffer_size; + UInt8 write_protect; + UInt8 logical_track; + UInt8 address_latch, data_latch; +} stateDisk[2] = {0}; +UInt32 DskIoICountDiff = 0; +UInt32 LastDskIoICount = 0; + +/* + * SLOT 6 IO read. + */ +RDMEM_CWRAP(SLT6, address) +{ + return (BootROM[address & 0xFF]); +} +void setCurrentDisk(int drive) +{ + if (drive != drive_no) + { + if (drive_no) + showDriveState(drive_no, false); + drive_no = drive; + showDiskName(drive_no, stateDisk[drive_no - 1].diskname); + showDriveState(drive_no, motor_state); + } + drive--; + track_buffer_valid = stateDisk[drive].track_buffer_valid; + write_mode = stateDisk[drive].write_mode; + nibble_buf = stateDisk[drive].nibble_buf; + track_buffer_pos = stateDisk[drive].track_buffer_pos; + track_buffer_size = stateDisk[drive].track_buffer_size; + write_protect = stateDisk[drive].write_protect; + address_latch = stateDisk[drive].address_latch; + data_latch = stateDisk[drive].data_latch; +} +int getCurrentDrive(void) +{ + return (drive_no | (motor_state ? 0x80 : 0)); +} +void updateCurrentDisk(int drive) +{ + if (drive--) + { + stateDisk[drive].track_buffer_pos = track_buffer_pos; + stateDisk[drive].address_latch = address_latch; + stateDisk[drive].data_latch = data_latch; + } +} +void load_track_buffer(int drive) +{ + UInt8 *values; + + if (stateDisk[--drive].diskdb) + { + stateDisk[drive].logical_track = (stateDisk[drive].physical_track_no + 1) >> 2; + if (stateDisk[drive].logical_track >= stateDisk[drive].track_count) + stateDisk[drive].logical_track = stateDisk[drive].track_count - 1; + if ((stateDisk[drive].logical_track != stateDisk[drive].last_track) || !stateDisk[drive].track_buffer_valid) + { + if (stateDisk[drive].track_buffer_dirty && !stateDisk[drive].track_buffer_raw) + { + stateDisk[drive].track_buffer_handle = DmGetRecord(stateDisk[drive].diskimage, stateDisk[drive].last_track); + values = (UInt8 *) MemHandleLock(stateDisk[drive].track_buffer_handle); + NibblesToSectors(stateDisk[drive].nibble_buf, values, 254, stateDisk[drive].last_track); + MemHandleUnlock(stateDisk[drive].track_buffer_handle); + DmReleaseRecord(stateDisk[drive].diskimage, stateDisk[drive].last_track, true); + } + else if (stateDisk[drive].track_buffer_handle) + MemHandleUnlock(stateDisk[drive].track_buffer_handle); + stateDisk[drive].track_buffer_handle = DmQueryRecord(stateDisk[drive].diskimage, stateDisk[drive].logical_track); + values = (UInt8 *) MemHandleLock(stateDisk[drive].track_buffer_handle); + if (stateDisk[drive].track_buffer_raw) + stateDisk[drive].nibble_buf = values; + else + { + SectorsToNibbles(values, stateDisk[drive].nibble_buf, 254, stateDisk[drive].logical_track); + MemHandleUnlock(stateDisk[drive].track_buffer_handle); + stateDisk[drive].track_buffer_handle = 0; + } + stateDisk[drive].last_track = stateDisk[drive].logical_track; + stateDisk[drive].track_buffer_track = stateDisk[drive].physical_track_no; + stateDisk[drive].track_buffer_dirty = false; + stateDisk[drive].track_buffer_valid = true; + stateDisk[drive].track_buffer_pos = 0; + if (drive_no == (drive + 1)) + setCurrentDisk(drive_no); + } + } +} +void write_nibble(UInt8 data) +{ + if (!track_buffer_valid) + load_track_buffer(drive_no); + else if (DskIoICountDiff > 100) + { + if (DskIoICountDiff < 65536) + { + /* + * Advance position based on instruction count. + */ + track_buffer_pos += (DskIoICountDiff >> 12) * (track_buffer_size >> 4); /* divide by ~4096 instructions per sector */ + if (track_buffer_pos >= track_buffer_size) + track_buffer_pos -= track_buffer_size; + } + if (track_buffer_size == RAW_TRACK_BYTES) + { + /* + * Round position up to a sector boundary. + */ + if (track_buffer_pos > RAW_SECTOR_BYTES*15) + track_buffer_pos = 0; + else if (track_buffer_pos > RAW_SECTOR_BYTES*14) + track_buffer_pos = RAW_SECTOR_BYTES*15; + else if (track_buffer_pos > RAW_SECTOR_BYTES*13) + track_buffer_pos = RAW_SECTOR_BYTES*14; + else if (track_buffer_pos > RAW_SECTOR_BYTES*12) + track_buffer_pos = RAW_SECTOR_BYTES*13; + else if (track_buffer_pos > RAW_SECTOR_BYTES*11) + track_buffer_pos = RAW_SECTOR_BYTES*12; + else if (track_buffer_pos > RAW_SECTOR_BYTES*10) + track_buffer_pos = RAW_SECTOR_BYTES*11; + else if (track_buffer_pos > RAW_SECTOR_BYTES*9) + track_buffer_pos = RAW_SECTOR_BYTES*10; + else if (track_buffer_pos > RAW_SECTOR_BYTES*8) + track_buffer_pos = RAW_SECTOR_BYTES*9; + else if (track_buffer_pos > RAW_SECTOR_BYTES*7) + track_buffer_pos = RAW_SECTOR_BYTES*8; + else if (track_buffer_pos > RAW_SECTOR_BYTES*6) + track_buffer_pos = RAW_SECTOR_BYTES*7; + else if (track_buffer_pos > RAW_SECTOR_BYTES*5) + track_buffer_pos = RAW_SECTOR_BYTES*6; + else if (track_buffer_pos > RAW_SECTOR_BYTES*4) + track_buffer_pos = RAW_SECTOR_BYTES*5; + else if (track_buffer_pos > RAW_SECTOR_BYTES*3) + track_buffer_pos = RAW_SECTOR_BYTES*4; + else if (track_buffer_pos > RAW_SECTOR_BYTES*2) + track_buffer_pos = RAW_SECTOR_BYTES*3; + else if (track_buffer_pos > RAW_SECTOR_BYTES*1) + track_buffer_pos = RAW_SECTOR_BYTES*2; + else if (track_buffer_pos > RAW_SECTOR_BYTES*0) + track_buffer_pos = RAW_SECTOR_BYTES*1; + } + } + nibble_buf[track_buffer_pos] = data; + if (++track_buffer_pos >= track_buffer_size) + track_buffer_pos = 0; + stateDisk[drive_no - 1].track_buffer_dirty = true; +} +UInt8 read_nibble() +{ + UInt8 data; + + if (!track_buffer_valid) + load_track_buffer(drive_no); + else if (DskIoICountDiff > 100) + { + if (DskIoICountDiff < 65536) + { + /* + * Advance position based on instruction count. + */ + track_buffer_pos += (DskIoICountDiff >> 12) * (track_buffer_size >> 4); /* divide by ~4096 instructions per sector */ + if (track_buffer_pos >= track_buffer_size) + track_buffer_pos -= track_buffer_size; + } + if (track_buffer_size == RAW_TRACK_BYTES) + { + /* + * Round position up to a sector boundary. + */ + if (track_buffer_pos > RAW_SECTOR_BYTES*15) + track_buffer_pos = 0; + else if (track_buffer_pos > RAW_SECTOR_BYTES*14) + track_buffer_pos = RAW_SECTOR_BYTES*15; + else if (track_buffer_pos > RAW_SECTOR_BYTES*13) + track_buffer_pos = RAW_SECTOR_BYTES*14; + else if (track_buffer_pos > RAW_SECTOR_BYTES*12) + track_buffer_pos = RAW_SECTOR_BYTES*13; + else if (track_buffer_pos > RAW_SECTOR_BYTES*11) + track_buffer_pos = RAW_SECTOR_BYTES*12; + else if (track_buffer_pos > RAW_SECTOR_BYTES*10) + track_buffer_pos = RAW_SECTOR_BYTES*11; + else if (track_buffer_pos > RAW_SECTOR_BYTES*9) + track_buffer_pos = RAW_SECTOR_BYTES*10; + else if (track_buffer_pos > RAW_SECTOR_BYTES*8) + track_buffer_pos = RAW_SECTOR_BYTES*9; + else if (track_buffer_pos > RAW_SECTOR_BYTES*7) + track_buffer_pos = RAW_SECTOR_BYTES*8; + else if (track_buffer_pos > RAW_SECTOR_BYTES*6) + track_buffer_pos = RAW_SECTOR_BYTES*7; + else if (track_buffer_pos > RAW_SECTOR_BYTES*5) + track_buffer_pos = RAW_SECTOR_BYTES*6; + else if (track_buffer_pos > RAW_SECTOR_BYTES*4) + track_buffer_pos = RAW_SECTOR_BYTES*5; + else if (track_buffer_pos > RAW_SECTOR_BYTES*3) + track_buffer_pos = RAW_SECTOR_BYTES*4; + else if (track_buffer_pos > RAW_SECTOR_BYTES*2) + track_buffer_pos = RAW_SECTOR_BYTES*3; + else if (track_buffer_pos > RAW_SECTOR_BYTES*1) + track_buffer_pos = RAW_SECTOR_BYTES*2; + else if (track_buffer_pos > RAW_SECTOR_BYTES*0) + track_buffer_pos = RAW_SECTOR_BYTES*1; + } + } + data = nibble_buf[track_buffer_pos]; + if (++track_buffer_pos >= track_buffer_size) + track_buffer_pos = 0; + return (data); +} +void toggleStepper(int drive, UInt8 magnet, UInt8 on) +{ + if (drive--) + { + if (on) + stateDisk[drive].stepper_status |= (1 << magnet); + else + stateDisk[drive].stepper_status &= ~(1 << magnet); + if (motor_state) + { + stateDisk[drive].physical_track_no += stepper_movement_table[stateDisk[drive].stepper_status][stateDisk[drive].physical_track_no & 0x07]; + if (stateDisk[drive].physical_track_no < 0) + stateDisk[drive].physical_track_no = 0; + else if (stateDisk[drive].physical_track_no >= MAX_PHYSICAL_TRACK_NO) + stateDisk[drive].physical_track_no = MAX_PHYSICAL_TRACK_NO - 1; + stateDisk[drive].track_buffer_valid = track_buffer_valid = false; + } + } +} +void toggleMotor(int drive, Boolean on_off) +{ + if (drive--) + { + if (motor_state != on_off) + { + motor_state = on_off; + showDriveState(drive_no, motor_state); + } + } +} +void positionDisk(int drive, UInt16 new_track, UInt16 new_position) +{ + drive--; + stateDisk[drive].physical_track_no = new_track << 2; + if (stateDisk[drive].physical_track_no >= MAX_PHYSICAL_TRACK_NO) + stateDisk[drive].physical_track_no = MAX_PHYSICAL_TRACK_NO - 1; + load_track_buffer(drive + 1); + stateDisk[drive].track_buffer_pos = new_position; + if (stateDisk[drive].track_buffer_pos >= stateDisk[drive].track_buffer_size) + stateDisk[drive].track_buffer_pos = 0; + if (drive_no == (drive + 1)) + setCurrentDisk(drive_no); +} +void queryDisk(int drive, UInt16 *track, UInt16 *pos) +{ + if (drive-- == drive_no) + updateCurrentDisk(drive_no); + *track = stateDisk[drive].physical_track_no >> 2; + *pos = stateDisk[drive].track_buffer_pos; +} +int mountDisk(int drive, char *file, Boolean writeable) +{ + UInt16 attrs; + UInt32 type, numrecs, ttlbytes, recbytes; + umountDisk(drive--); + stateDisk[drive].track_buffer_pos = 0; + stateDisk[drive].track_buffer_dirty = false; + stateDisk[drive].diskdb = file ? DmFindDatabase(0, file) : 0; + if (stateDisk[drive].diskdb) + { + StrCopy(stateDisk[drive].diskname, file); + stateDisk[drive].diskimage = DmOpenDatabase(0, stateDisk[drive].diskdb, 0); + DmDatabaseInfo(0, stateDisk[drive].diskdb, NULL, &attrs, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &type, NULL); + stateDisk[drive].track_buffer_raw = (type == (UInt32)'RDSK') ? true : false; + stateDisk[drive].write_protect = attrs & dmHdrAttrReadOnly ? true : !writeable; + DmDatabaseSize(0, stateDisk[drive].diskdb, &numrecs, &ttlbytes, &recbytes); + stateDisk[drive].track_count = numrecs; + if (stateDisk[drive].track_buffer_raw) + { + stateDisk[drive].track_buffer_size = recbytes / stateDisk[drive].track_count; + } + else + { + stateDisk[drive].nibble_buf = MemPtrNew(RAW_TRACK_BYTES); + stateDisk[drive].track_buffer_size = RAW_TRACK_BYTES; + init_GCR_table(); + } + stateDisk[drive].track_buffer_handle = 0; + stateDisk[drive].track_buffer_valid = false; + } + else + { + stateDisk[drive].diskname[0] = '\0'; + stateDisk[drive].diskimage = 0; + stateDisk[drive].nibble_buf = MemPtrNew(RAW_TRACK_BYTES); + MemSet(stateDisk[drive].nibble_buf, RAW_TRACK_BYTES, 0xFF); + stateDisk[drive].track_buffer_handle = 0; + stateDisk[drive].track_buffer_size = RAW_TRACK_BYTES; + stateDisk[drive].track_buffer_valid = true; + stateDisk[drive].write_protect = true; + } + if (drive_no == (drive + 1)) + { + drive_no = 0; + setCurrentDisk(drive + 1); + } + else + { + showDiskName(drive + 1, stateDisk[drive].diskname); + showDriveState(drive + 1, false); + } + return (stateDisk[drive].diskdb != 0); +} +void umountDisk(int drive) +{ + UInt8 *values; + + if (drive-- == drive_no) + updateCurrentDisk(drive_no); + if (stateDisk[drive].diskdb) + { + if (!stateDisk[drive].track_buffer_raw) + { + if (stateDisk[drive].track_buffer_dirty) + { + stateDisk[drive].track_buffer_handle = DmGetRecord(stateDisk[drive].diskimage, stateDisk[drive].last_track); + values = (UInt8 *) MemHandleLock(stateDisk[drive].track_buffer_handle); + NibblesToSectors(stateDisk[drive].nibble_buf, values, 254, stateDisk[drive].last_track); + MemHandleUnlock(stateDisk[drive].track_buffer_handle); + DmReleaseRecord(stateDisk[drive].diskimage, stateDisk[drive].last_track, true); + } + MemPtrFree(stateDisk[drive].nibble_buf); + } + else if (stateDisk[drive].track_buffer_handle) + { + MemHandleUnlock(stateDisk[drive].track_buffer_handle); + } + DmCloseDatabase(stateDisk[drive].diskimage); + stateDisk[drive].diskdb = 0; + } + else if (stateDisk[drive].nibble_buf) + MemPtrFree(stateDisk[drive].nibble_buf); + stateDisk[drive].nibble_buf = NULL; + stateDisk[drive].track_buffer_handle = 0; + stateDisk[drive].track_buffer_valid = false; + toggleMotor(drive + 1, 0); +} +void resetDisks(void) +{ +#if 0 + UInt8 drive, *values; + + updateCurrentDisk(drive_no); + for (drive = 0; drive < 2; drive++) + { + if (stateDisk[drive].diskdb) + { + if (!stateDisk[drive].track_buffer_raw) + { + if (stateDisk[drive].track_buffer_dirty) + { + stateDisk[drive].track_buffer_handle = DmGetRecord(stateDisk[drive].diskimage, stateDisk[drive].last_track); + values = (UInt8 *) MemHandleLock(stateDisk[drive].track_buffer_handle); + NibblesToSectors(stateDisk[drive].nibble_buf, values, 254, stateDisk[drive].last_track); + MemHandleUnlock(stateDisk[drive].track_buffer_handle); + DmReleaseRecord(stateDisk[drive].diskimage, stateDisk[drive].last_track, true); + } + } + else if (stateDisk[drive].track_buffer_handle) + { + MemHandleUnlock(stateDisk[drive].track_buffer_handle); + } + } + toggleMotor(drive + 1, 0); + stateDisk[drive].physical_track_no = 0; + stateDisk[drive].track_buffer_handle = 0; + stateDisk[drive].track_buffer_pos = 0; + stateDisk[drive].track_buffer_valid = false; + stateDisk[drive].track_buffer_dirty = false; + } +#else + umountDisk(1); + umountDisk(2); + mountDisk(1, stateDisk[0].diskname, stateDisk[0].write_protect); + mountDisk(2, stateDisk[1].diskname, stateDisk[1].write_protect); +#endif + drive_no = 0; + setCurrentDisk(1); +} + +/*****************************************************************************\ +* * +* I/O page access * +* * +\*****************************************************************************/ + +/* + * I/O Read. + */ +UInt8 RIOM(UInt16); +UInt8 cwrap_RIOM(UInt16); +UInt8 awrap_RIOM(UInt16 a) +{ + asm(".global RIOM"); + asm("RIOM:"); + /* + * Quick check for Disk read byte. + */ + asm("cmp.b #0xEC, %d6"); + asm("bne.b L1"); + /* + * Check for buffer valid. + */ + asm("tst.b track_buffer_valid@END.w(%a5)"); + asm("beq.b L1"); + /* + * Update access time. + */ + asm("move.l AppleInstrInc@END.w(%a5), %d0"); + asm("sub.l %d1, %d0"); + asm("add.l AppleInstrCount@END.w(%a5), %d0"); + asm("move.l %d0, %a6"); + asm("sub.l LastDskIoICount@END.w(%a5), %d0"); + asm("move.l %d0, DskIoICountDiff@END.w(%a5)"); + asm("move.l %a6, LastDskIoICount@END.w(%a5)"); + /* + * Check for back-to-back read. + */ + asm("cmp.l #100, %d0"); // This is the instruction count that determines if it is back-to-back + asm("bgt.b L1"); + /* + * Check for read or write. + */ + asm("tst.b write_mode@END.w(%a5)"); + asm("bne.b L1"); + /* + * Read next byte in buffer and advance position. + */ + asm("move.w track_buffer_pos@END.w(%a5), %a6"); + asm("move.l nibble_buf@END.w(%a5), %d0"); + asm("move.b (%a6,%d0.l), %d0"); + asm("exg %a6, %d0"); + asm("addq.w #1, %d0"); + asm("cmp.w track_buffer_size@END.w(%a5), %d0"); + asm("blt.b L2"); + asm("clr.w %d0"); + asm("L2:"); + asm("move.w %d0, track_buffer_pos@END.w(%a5)"); + asm("exg %a6, %d0"); + asm("and.l #0xFF, %d0"); + asm("move.b #0x0C, address_latch@END.w(%a5)"); // Update address latch + asm("rts"); + /* + * Call C-wrapped function. + */ + asm("L1:"); + asm("movem.l #0x1FFE, (state6502+4)@END.w(%a5)"); + asm("move.w %d6, -(%sp)"); + asm("bsr.w cwrap_RIOM"); + asm("addq.l #2, %sp"); + asm("and.l #0xFF,%d0"); + asm("movem.l (state6502+4)@END.w(%a5), #0x1FFE"); + asm("rts"); +} +UInt8 cwrap_RIOM(UInt16 address) +{ + UInt8 data = 0; + + switch ((UInt8)address) + { + case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07: + case 0x08: case 0x09: case 0x0A: case 0x0B: case 0x0C: case 0x0D: case 0x0E: case 0x0F: + data = kbdIOU; + break; + case 0x10: + data = kbdIOU & 0x7F; + if (kbdCount) + { + kbdHead = (kbdHead + 1) & KBD_BUF_MASK; + if (--kbdCount) + kbdIOU = kbdBuffer[kbdHead]; + else + kbdIOU &= 0x7F; + } + else + kbdIOU &= 0x7F; + break; + case 0x11: + if (SS_ISSET(memIOU, SS_LCBNK2)) + data = 0x80; + break; + case 0x12: + data = 0x80; + break; + case 0x13: + if (SS_ISSET(memIOU, SS_LCRAMMAP)) + data = 0x80; + break; + case 0x14: + if (SS_ISSET(memIOU, SS_LCRAMWRT)) + data = 0x80; + break; + case 0x15: + if (SS_ISSET(memIOU, SS_SLOTCXROM)) + data = 0x80; + break; + case 0x16: + break; + case 0x17: + if (SS_ISSET(memIOU, SS_SLOTC3ROM)) + data = 0x80; + break; + case 0x18: + if (SS_ISSET(vidIOU, SS_80STORE)) + data = 0x80; + break; + case 0x19: + if (SS_ISSET(vidIOU, SS_VBLBAR)) + data = 0x80; + break; + case 0x1A: + if (SS_ISSET(vidIOU, SS_TEXT)) + data = 0x80; + break; + case 0x1B: + if (SS_ISSET(vidIOU, SS_MIXED)) + data = 0x80; + break; + case 0x1C: + if (SS_ISSET(vidIOU, SS_PAGE2)) + data = 0x80; + break; + case 0x1D: + if (SS_ISSET(vidIOU, SS_HIRES)) + data = 0x80; + break; + case 0x1E: + break; + case 0x1F: + if (SS_ISSET(vidIOU, SS_80VID)) + data = 0x80; + break; + case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27: + case 0x28: case 0x29: case 0x2A: case 0x2B: case 0x2C: case 0x2D: case 0x2E: case 0x2F: + break; + case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37: + case 0x38: case 0x39: case 0x3A: case 0x3B: case 0x3C: case 0x3D: case 0x3E: case 0x3F: + spkrIOU++; + break; + case 0x40: case 0x41: case 0x42: case 0x43: case 0x44: case 0x45: case 0x46: case 0x47: + case 0x48: case 0x49: case 0x4A: case 0x4B: case 0x4C: case 0x4D: case 0x4E: case 0x4F: + break; + case 0x50: case 0x51: case 0x52: case 0x53: case 0x54: case 0x55: case 0x56: case 0x57: + case 0x58: case 0x59: case 0x5A: case 0x5B: case 0x5C: case 0x5D: case 0x5E: case 0x5F: + toggleVideoSoftSwitch(IO_OFFSET(address)); + break; + case 0x60: + break; + case 0x61: + if (btnIOU[0]) + data = 0x80; + break; + case 0x62: + if (btnIOU[1]) + data = 0x80; + break; + case 0x63: + if (btnIOU[2]) + data = 0x80; + break; + case 0x64: + if (pdlIOU[0]) + { + pdlIOU[0]--; + data = 0x80; + } + break; + case 0x65: + if (pdlIOU[1]) + { + pdlIOU[1]--; + data = 0x80; + } + break; + case 0x66: case 0x67: case 0x68: case 0x69: case 0x6A: case 0x6B: + break; + case 0x6C: + if (pdlIOU[0]) + { + pdlIOU[0]--; + data = 0x80; + } + break; + case 0x6D: + if (pdlIOU[1]) + { + pdlIOU[1]--; + data = 0x80; + } + break; + case 0x6E: + case 0x6F: + break; + case 0x70: case 0x71: case 0x72: case 0x73: case 0x74: case 0x75: case 0x76: case 0x77: + case 0x78: case 0x79: case 0x7A: case 0x7B: case 0x7C: case 0x7D: case 0x7E: case 0x7F: + pdlIOU[0] = pdlResetIOU[0]; + pdlIOU[1] = pdlResetIOU[1]; + break; + case 0x80: case 0x81: case 0x82: case 0x83: case 0x84: case 0x85: case 0x86: case 0x87: + case 0x88: case 0x89: case 0x8A: case 0x8B: case 0x8C: case 0x8D: case 0x8E: case 0x8F: + toggleLanguageCard(IO_OFFSET(address)); + break; + case 0x90: case 0x91: case 0x92: case 0x93: case 0x94: case 0x95: case 0x96: case 0x97: + case 0x98: case 0x99: case 0x9A: case 0x9B: case 0x9C: case 0x9D: case 0x9E: case 0x9F: + break; + case 0xA0: case 0xA1: case 0xA2: case 0xA3: case 0xA4: case 0xA5: case 0xA6: case 0xA7: + case 0xA8: case 0xA9: case 0xAA: case 0xAB: case 0xAC: case 0xAD: case 0xAE: case 0xAF: + break; + case 0xB0: case 0xB1: case 0xB2: case 0xB3: case 0xB4: case 0xB5: case 0xB6: case 0xB7: + case 0xB8: case 0xB9: case 0xBA: case 0xBB: case 0xBC: case 0xBD: case 0xBE: case 0xBF: + break; + case 0xC0: case 0xC1: case 0xC2: case 0xC3: case 0xC4: case 0xC5: case 0xC6: case 0xC7: + case 0xC8: case 0xC9: case 0xCA: case 0xCB: case 0xCC: case 0xCD: case 0xCE: case 0xCF: + break; + case 0xD0: case 0xD1: case 0xD2: case 0xD3: case 0xD4: case 0xD5: case 0xD6: case 0xD7: + case 0xD8: case 0xD9: case 0xDA: case 0xDB: case 0xDC: case 0xDD: case 0xDE: case 0xDF: + break; + case 0xE0: case 0xE1: case 0xE2: case 0xE3: case 0xE4: case 0xE5: case 0xE6: case 0xE7: + toggleStepper(drive_no, (address >> 1) & 0x07, address & 1); + break; + case 0xE8: + toggleMotor(drive_no, 0); + break; + case 0xE9: + toggleMotor(drive_no, 1); + break; + case 0xEA: + if (drive_no != 1) + { + updateCurrentDisk(drive_no); + setCurrentDisk(1); + } + break; + case 0xEB: + if (drive_no != 2) + { + updateCurrentDisk(drive_no); + setCurrentDisk(2); + } + break; + case 0xEC: + if (write_mode) + write_nibble(data_latch); + else + data = read_nibble(); + address_latch = 0x0C; + break; + case 0xED: + address_latch = 0x0D; + break; + case 0xEE: + if (address_latch == 0x0D) + /* check write protect */ + data = write_protect ? 0xFF: 0x00; + address_latch = 0x0E; + write_mode = 0; + break; + case 0xEF: + address_latch = 0x0F; + write_mode = 1; + break; + case 0xF0: + case 0xF1: + case 0xF2: + case 0xF3: + case 0xF4: + case 0xF5: + case 0xF6: + case 0xF7: + case 0xF8: + case 0xF9: + case 0xFA: + case 0xFB: + case 0xFC: + case 0xFD: + case 0xFE: + case 0xFF: + break; + } + return (data); +} +/* + * I/O Write. + */ +void WIOM(UInt16, UInt8); +void cwrap_WIOM(UInt16, UInt8); +void awrap_wIOM(UInt16 a, UInt8 d) +{ + asm(".global WIOM"); + asm("WIOM:"); + /* + * Quick check for Disk read byte. + */ + asm("cmp.b #0xEC, %d6"); + asm("bne.b L3"); + /* + * Update IO access time. + */ + asm("move.l %d0, %a6"); + asm("move.l AppleInstrInc@END.w(%a5), %d0"); + asm("sub.l %d1, %d0"); + asm("add.l AppleInstrCount@END.w(%a5), %d0"); + asm("sub.l LastDskIoICount@END.w(%a5), %d0"); + asm("move.l %d0, DskIoICountDiff@END.w(%a5)"); + asm("add.l %d0, LastDskIoICount@END.w(%a5)"); + asm("move.l %a6, %d0"); + /* + * Call C-wrapped function. + */ + asm("L3:"); + asm("movem.l #0x1FFF, state6502@END.w(%a5)"); + asm("move.b %d0, -(%sp)"); + asm("move.w %d6, -(%sp)"); + asm("bsr.w cwrap_WIOM"); + asm("addq.l #4, %sp"); + asm("movem.l state6502@END.w(%a5), #0x1FFF"); + asm("rts"); +} +void cwrap_WIOM(UInt16 address, UInt8 data) +{ + AppleMemory[address] = data; + switch ((UInt8)address) + { + case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07: + case 0x08: case 0x09: case 0x0A: case 0x0B: case 0x0C: case 0x0D: case 0x0E: case 0x0F: + writeMemorySoftSwitch(IO_OFFSET(address)); + break; + case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17: + case 0x18: case 0x19: case 0x1A: case 0x1B: case 0x1C: case 0x1D: case 0x1E: case 0x1F: + if (kbdCount) + { + kbdHead = (kbdHead + 1) & KBD_BUF_MASK; + if (--kbdCount) + kbdIOU = kbdBuffer[kbdHead]; + else + kbdIOU &= 0x7F; + } + else + kbdIOU &= 0x7F; + break; + case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27: + case 0x28: case 0x29: case 0x2A: case 0x2B: case 0x2C: case 0x2D: case 0x2E: case 0x2F: + break; + case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37: + case 0x38: case 0x39: case 0x3A: case 0x3B: case 0x3C: case 0x3D: case 0x3E: case 0x3F: + spkrIOU++; + break; + case 0x40: case 0x41: case 0x42: case 0x43: case 0x44: case 0x45: case 0x46: case 0x47: + case 0x48: case 0x49: case 0x4A: case 0x4B: case 0x4C: case 0x4D: case 0x4E: case 0x4F: + break; + case 0x50: case 0x51: case 0x52: case 0x53: case 0x54: case 0x55: case 0x56: case 0x57: + case 0x58: case 0x59: case 0x5A: case 0x5B: case 0x5C: case 0x5D: case 0x5E: case 0x5F: + toggleVideoSoftSwitch(IO_OFFSET(address)); + break; + case 0x60: case 0x61: case 0x62: case 0x63: case 0x64: case 0x65: case 0x66: case 0x67: + case 0x68: case 0x69: case 0x6A: case 0x6B: case 0x6C: case 0x6D: case 0x6E: case 0x6F: + break; + case 0x70: case 0x71: case 0x72: case 0x73: case 0x74: case 0x75: case 0x76: case 0x77: + case 0x78: case 0x79: case 0x7A: case 0x7B: case 0x7C: case 0x7D: case 0x7E: case 0x7F: + pdlIOU[0] = pdlResetIOU[0]; + pdlIOU[1] = pdlResetIOU[1]; + break; + case 0x80: case 0x81: case 0x82: case 0x83: case 0x84: case 0x85: case 0x86: case 0x87: + case 0x88: case 0x89: case 0x8A: case 0x8B: case 0x8C: case 0x8D: case 0x8E: case 0x8F: + toggleLanguageCard(IO_OFFSET(address)); + break; + case 0x90: case 0x91: case 0x92: case 0x93: case 0x94: case 0x95: case 0x96: case 0x97: + case 0x98: case 0x99: case 0x9A: case 0x9B: case 0x9C: case 0x9D: case 0x9E: case 0x9F: + break; + case 0xA0: case 0xA1: case 0xA2: case 0xA3: case 0xA4: case 0xA5: case 0xA6: case 0xA7: + case 0xA8: case 0xA9: case 0xAA: case 0xAB: case 0xAC: case 0xAD: case 0xAE: case 0xAF: + break; + case 0xB0: case 0xB1: case 0xB2: case 0xB3: case 0xB4: case 0xB5: case 0xB6: case 0xB7: + case 0xB8: case 0xB9: case 0xBA: case 0xBB: case 0xBC: case 0xBD: case 0xBE: case 0xBF: + break; + case 0xC0: case 0xC1: case 0xC2: case 0xC3: case 0xC4: case 0xC5: case 0xC6: case 0xC7: + case 0xC8: case 0xC9: case 0xCA: case 0xCB: case 0xCC: case 0xCD: case 0xCE: case 0xCF: + break; + case 0xD0: case 0xD1: case 0xD2: case 0xD3: case 0xD4: case 0xD5: case 0xD6: case 0xD7: + case 0xD8: case 0xD9: case 0xDA: case 0xDB: case 0xDC: case 0xDD: case 0xDE: case 0xDF: + break; + case 0xE0: case 0xE1: case 0xE2: case 0xE3: case 0xE4: case 0xE5: case 0xE6: case 0xE7: + toggleStepper(drive_no, (address >> 1) & 0x07, address & 1); + break; + case 0xE8: + toggleMotor(drive_no, 0); + break; + case 0xE9: + toggleMotor(drive_no, 1); + break; + case 0xEA: + if (drive_no != 1) + { + updateCurrentDisk(drive_no); + setCurrentDisk(1); + } + break; + case 0xEB: + if (drive_no != 2) + { + updateCurrentDisk(drive_no); + setCurrentDisk(2); + } + break; + case 0xEC: + if (write_mode) + write_nibble(data_latch); + else + read_nibble(); + address_latch = 0x0C; + break; + case 0xED: + data_latch = data; + address_latch = 0x0D; + break; + case 0xEE: + address_latch = 0x0E; + write_mode = 0; + break; + case 0xEF: + data_latch = data; + address_latch = 0x0F; + write_mode = 1; + break; + case 0xF0: case 0xF1: case 0xF2: case 0xF3: case 0xF4: case 0xF5: case 0xF6: case 0xF7: + case 0xF8: case 0xF9: case 0xFA: case 0xFB: case 0xFC: case 0xFD: case 0xFE: case 0xFF: + break; + } +} + +/*****************************************************************************\ +* * +* Sector <=> Nibble Encoding * +* * +\*****************************************************************************/ + +static UInt8 GCR_encoding_table[64] = { + 0x96, 0x97, 0x9A, 0x9B, 0x9D, 0x9E, 0x9F, 0xA6, + 0xA7, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB2, 0xB3, + 0xB4, 0xB5, 0xB6, 0xB7, 0xB9, 0xBA, 0xBB, 0xBC, + 0xBD, 0xBE, 0xBF, 0xCB, 0xCD, 0xCE, 0xCF, 0xD3, + 0xD6, 0xD7, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, + 0xDF, 0xE5, 0xE6, 0xE7, 0xE9, 0xEA, 0xEB, 0xEC, + 0xED, 0xEE, 0xEF, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, + 0xF7, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF }; + +static UInt8 GCR_decoding_table[256]; +static UInt8 Swap_Bit[4] = { 0, 2, 1, 3 }; /* swap lower 2 bits */ +static UInt8 GCR_buffer[256]; +static UInt8 GCR_buffer2[86]; + +static UInt16 Position=0; +static UInt8 *Track_Nibble; + +/* physical sector no. to DOS 3.3 logical sector no. table */ +static UInt8 Logical_Sector[16] = { + 0x0, 0x7, 0xE, 0x6, 0xD, 0x5, 0xC, 0x4, + 0xB, 0x3, 0xA, 0x2, 0x9, 0x1, 0x8, 0xF }; + +static UInt8 Physical_Sector[16]; + + +#define FM_ENCODE(x) gcrWriteNibble( ((x) >> 1) | 0xAA );\ + gcrWriteNibble( (x) | 0xAA ) + +static void init_GCR_table(void) +{ + static UInt8 initialized = 0; + int i; + + if ( !initialized ) { + for( i = 0; i < 64; i++ ) + GCR_decoding_table[GCR_encoding_table[i]] = i; + for( i = 0; i < 16; i++ ) + Physical_Sector[Logical_Sector[i]] = i; + initialized = 1; + } +} + +static UInt8 gcr_read_nibble(void) +{ + UInt8 data; + + data = Track_Nibble[Position++]; + if ( Position >= RAW_TRACK_BYTES ) + Position = 0; + return data; +} + +static void gcr_write_nibble( UInt8 data ) +{ + Track_Nibble[Position++] = data; + if ( Position >= RAW_TRACK_BYTES ) + Position = 0; +} + +static void decode62( UInt8 *page ) +{ + int i, j; + + /* get 6 bits from GCR_buffer & 2 from GCR_buffer2 */ + for( i = 0, j = 86; i < 256; i++ ) { + if ( --j < 0 ) j = 85; + page[i] = (GCR_buffer[i] << 2) | Swap_Bit[GCR_buffer2[j] & 0x03]; + GCR_buffer2[j] >>= 2; + } +} + +static void encode62( UInt8 *page ) +{ + int i, j; + + /* 86 * 3 = 258, so the first two byte are encoded twice */ + GCR_buffer2[0] = Swap_Bit[page[1]&0x03]; + GCR_buffer2[1] = Swap_Bit[page[0]&0x03]; + + /* save higher 6 bits in GCR_buffer and lower 2 bits in GCR_buffer2 */ + for( i = 255, j = 2; i >= 0; i--, j = j == 85? 0: j + 1 ) { + GCR_buffer2[j] = (GCR_buffer2[j] << 2) | Swap_Bit[page[i]&0x03]; + GCR_buffer[i] = page[i] >> 2; + } + + /* clear off higher 2 bits of GCR_buffer2 set in the last call */ + for( i = 0; i < 86; i++ ) + GCR_buffer2[i] &= 0x3f; +} + +/* + * write an FM encoded value, used in writing address fields + */ +static void FM_encode( UInt8 data ) +{ + gcr_write_nibble( (data >> 1) | 0xAA ); + gcr_write_nibble( data | 0xAA ); +} + +/* + * return an FM encoded value, used in reading address fields + */ +static UInt8 FM_decode(void) +{ + int tmp; + + /* C does not specify order of operand evaluation, don't + * merge the following two expression into one + */ + tmp = (gcr_read_nibble() << 1) | 0x01; + return gcr_read_nibble() & tmp; +} + +static void write_sync( int length ) +{ + while( length-- ) + gcr_write_nibble( 0xFF ); +} + +/* + * read_address_field: try to read a address field in a track + * returns 1 if succeed, 0 otherwise + */ +static int read_address_field( int *volume, int *track, int *sector ) +{ + int max_try; + UInt8 nibble; + + max_try = 100; + while( --max_try ) { + nibble = gcr_read_nibble(); + check_D5: + if ( nibble != 0xD5 ) + continue; + nibble = gcr_read_nibble(); + if ( nibble != 0xAA ) + goto check_D5; + nibble = gcr_read_nibble(); + if ( nibble != 0x96 ) + goto check_D5; + *volume = FM_decode(); + *track = FM_decode(); + *sector = FM_decode(); + return ( *volume ^ *track ^ *sector ) == FM_decode() && + gcr_read_nibble() == 0xDE; + } + return 0; +} + +static void write_address_field( int volume, int track, int sector ) +{ + /* + * write address mark + */ + gcr_write_nibble( 0xD5 ); + gcr_write_nibble( 0xAA ); + gcr_write_nibble( 0x96 ); + + /* + * write Volume, Track, Sector & Check-sum + */ + FM_encode( volume ); + FM_encode( track ); + FM_encode( sector ); + FM_encode( volume ^ track ^ sector ); + + /* + * write epilogue + */ + gcr_write_nibble( 0xDE ); + gcr_write_nibble( 0xAA ); + gcr_write_nibble( 0xEB ); +} + +/* + * read_data_field: read_data_field into GCR_buffers, return 0 if fail + */ +static int read_data_field(void) +{ + int i, max_try; + UInt8 nibble, checksum; + + /* + * read data mark + */ + max_try = 32; + while( --max_try ) { + nibble = gcr_read_nibble(); + check_D5: + if ( nibble != 0xD5 ) + continue; + nibble = gcr_read_nibble(); + if ( nibble != 0xAA ) + goto check_D5; + nibble = gcr_read_nibble(); + if ( nibble == 0xAD ) + break; + } + if ( !max_try ) /* fails to get address mark */ + return 0; + + for( i = 0x55, checksum = 0; i >= 0; i-- ) { + checksum ^= GCR_decoding_table[gcr_read_nibble()]; + GCR_buffer2[i] = checksum; + } + + for( i = 0; i < 256; i++ ) { + checksum ^= GCR_decoding_table[gcr_read_nibble()]; + GCR_buffer[i] = checksum; + } + + /* verify sector checksum */ + if ( checksum ^ GCR_decoding_table[gcr_read_nibble()] ) + return 0; + + /* check epilogue */ + return gcr_read_nibble() == 0xDE && gcr_read_nibble() == 0xAA; +} + +static void write_data_field(void) +{ + int i; + UInt8 last, checksum; + + /* write prologue */ + gcr_write_nibble( 0xD5 ); + gcr_write_nibble( 0xAA ); + gcr_write_nibble( 0xAD ); + + /* write GCR encode data */ + for( i = 0x55, last = 0; i >= 0; i-- ) { + checksum = last^ GCR_buffer2[i]; + gcr_write_nibble( GCR_encoding_table[checksum] ); + last = GCR_buffer2[i]; + } + for( i = 0; i < 256; i++ ) { + checksum = last ^ GCR_buffer[i]; + gcr_write_nibble( GCR_encoding_table[checksum] ); + last = GCR_buffer[i]; + } + + /* write checksum and epilogue */ + gcr_write_nibble( GCR_encoding_table[last] ); + gcr_write_nibble( 0xDE ); + gcr_write_nibble( 0xAA ); + gcr_write_nibble( 0xEB ); +} + +void SectorsToNibbles( UInt8 *sectors, UInt8 *nibbles, int volume, int track ) +{ + int i; + + Track_Nibble = nibbles; + Position = 0; + + /*write_sync( 128 );*/ + for( i = 0; i < 16; i ++ ) { + encode62( sectors + Logical_Sector[i] * 0x100 ); + write_sync( 16 ); + write_address_field( volume, track, i ); + write_sync( 8 ); + write_data_field(); + } +} + +int NibblesToSectors( UInt8 *nibbles, UInt8 *sectors, int volume, int track ) +{ + int i, scanned[16], max_try, sectors_read; + int vv, tt, ss; /* volume, track no. and sector no. */ + + Track_Nibble = nibbles; + Position = 0; + + for( i = 0; i < 16; i++ ) + scanned[i] = 0; + sectors_read = 0; + + max_try = 200; + while( --max_try ) { + if ( !read_address_field( &vv, &tt, &ss ) ) + continue; + + if ( (volume && vv != volume ) || tt != track || ss < 0 || ss > 15 ){ + //printf("phy sector %d address field invalid\n", ss ); + continue; /* invalid values for vv, tt and ss, try again */ + } + + ss = Logical_Sector[ss]; + if ( scanned[ss] ) /* sector has been read */ + continue; + + if ( read_data_field() ) { + decode62( sectors + ss * 0x100 ); + scanned[ss] = 1; /* this sector's ok */ + sectors_read++; + } + else { + //printf("fail reading data field of logical sector %d\n", ss ); + } + } + + /* if has failed to read any one sector, report error */ + if ( sectors_read == 16 ) + return 1; + else + return 0; +} + diff --git a/src/memory.h b/src/memory.h new file mode 100755 index 0000000..f7b4aec --- /dev/null +++ b/src/memory.h @@ -0,0 +1,71 @@ +typedef UInt8 (*READBYTE)(UInt16); +typedef void (*WRITEBYTE)(UInt16, UInt8); +typedef void (*VIDIMAGE)(void); +extern Boolean dirtyVideo; +extern UInt8 *AppleMemory; +extern UInt8 *AuxMemory; +extern UInt8 *AppleROM; +extern UInt8 *BootROM; +extern READBYTE *ReadFunction; +extern WRITEBYTE *WriteFunction; +extern VIDIMAGE updateVideo; +extern UInt16 clrPairEven[96], clrPairOdd[96], interpPairEven[96], interpPairOdd[96]; + +void initMemory(void); +void initVideo(void); +void setMemFuncs(void); +void setVideoFuncs(Boolean); +void loadROM(void); +int getCurrentDrive(void); +void showCurrentDisk(void); +int mountDisk(int, char *, Boolean); +void umountDisk(int); +void positionDisk(int, UInt16, UInt16); +void queryDisk(int, UInt16 *, UInt16 *); +void resetDisks(void); +/* + * Macros to wrap a C function for assembly linkeage to emulator + * memory R/W routines. + */ +#define WRMEM_CWRAP(fn,a,d) \ +void fn(UInt16,UInt8); \ +void cwrap_##fn(UInt16,UInt8); \ +void awrap_##fn(UInt16 a, UInt8 d) \ +{ \ + asm(".global "#fn); \ + asm(#fn ":"); \ + asm("movem.l #0x1FFF, state6502@END.w(%a5)"); \ + asm("move.b %d0, -(%sp)"); \ + asm("move.w %d6, -(%sp)"); \ + asm("bsr.w cwrap_"#fn); \ + asm("addq.l #4, %sp"); \ + asm("movem.l state6502@END.w(%a5), #0x1FFF"); \ + asm("rts"); \ +} \ +void cwrap_##fn(UInt16 a, UInt8 d) + +#define RDMEM_CWRAP(fn,a) \ +UInt8 fn(UInt16); \ +UInt8 cwrap_##fn(UInt16); \ +UInt8 awrap_##fn(UInt16 a) \ +{ \ + asm(".global "#fn); \ + asm(#fn ":"); \ + asm("movem.l #0x1FFE, (state6502+4)@END.w(%a5)");\ + asm("move.w %d6, -(%sp)"); \ + asm("bsr.w cwrap_"#fn); \ + asm("addq.l #2, %sp"); \ + asm("and.l #0xFF,%d0"); \ + asm("movem.l (state6502+4)@END.w(%a5), #0x1FFE");\ + asm("rts"); \ +} \ +UInt8 cwrap_##fn(UInt16 a) + +/* + * Keyboard type-ahead buffer. + */ +#define KBD_BUF_SIZE 16 +#define KBD_BUF_MASK 15 +extern UInt8 kbdBuffer[KBD_BUF_SIZE]; +extern UInt8 kbdHead, kbdCount; + diff --git a/src/vidclr.asm b/src/vidclr.asm new file mode 100755 index 0000000..4fadea0 --- /dev/null +++ b/src/vidclr.asm @@ -0,0 +1,816 @@ +#define SRC %a0 +#define DST %a1 +#define PIXPAIR %a2 +#define FONTBASE %a2 +#define FONT %a2 +#define CLR16BASE %a2 +#define ASRC %a3 +#define PIXPAIREVENTABLE %a3 +#define PIXMONOLOTABLE %a3 +#define ACACHE %a4 +#define PIXPAIRODDTABLE %a4 +#define PIXMONOHITABLE %a4 +#define CACHE %a6 +#define DSTDBL %a6 +#define BITMASK %d0 +#define PREFETCH %d1 +#define VCHAR %d1 +#define HCOUNT %d2 +#define VCOUNT %d3 +#define DATA %d6 +#define DATALO %d6 +#define MSBOFFSET %d7 +#define DATAHI %d7 + +.text +.even +/* + * Update a single HiRes scanline. + */ +.global gryUpdateHiresScanline +gryUpdateHiresScanline: + movm.l #0x133A, -(%sp) + move.l (28+4)(%sp), SRC + move.l (28+8)(%sp), DST + move.l HRMonoLo@END.w(%a5), PIXMONOLOTABLE + move.l HRMonoHi@END.w(%a5), PIXMONOHITABLE + clr.w DATAHI + move.w #19, HCOUNT +gryscanloop: + move.w (SRC)+, DATALO + and.w #0x7F7F, DATALO + move.b DATALO, DATAHI + lsr.w #8, DATALO + move.b (PIXMONOLOTABLE,DATALO.w), BITMASK + move.b DATAHI, PREFETCH + not.b PREFETCH + and.b #0x01, PREFETCH + or.b PREFETCH, BITMASK + lsl.w #8, BITMASK + move.b (PIXMONOHITABLE,DATAHI.w), BITMASK + not.b DATALO + and.b #0x40, DATALO + add.b DATALO, DATALO + or.b DATALO, BITMASK + move.w BITMASK, (DST)+ + dbf.w HCOUNT, gryscanloop + movm.l (%sp)+, #0x5CC8 + rts +.global clrUpdateHiresScanline +clrUpdateHiresScanline: + movm.l #0x133A, -(%sp) + move.l (28+4)(%sp), SRC + move.l (28+12)(%sp), CACHE + move.l (SRC)+, BITMASK + cmp.l (CACHE)+, BITMASK + bne clrcachedirty + move.l (SRC)+, BITMASK + cmp.l (CACHE)+, BITMASK + bne clrcachedirty + move.l (SRC)+, BITMASK + cmp.l (CACHE)+, BITMASK + bne clrcachedirty + move.l (SRC)+, BITMASK + cmp.l (CACHE)+, BITMASK + bne clrcachedirty + move.l (SRC)+, BITMASK + cmp.l (CACHE)+, BITMASK + bne clrcachedirty + move.l (SRC)+, BITMASK + cmp.l (CACHE)+, BITMASK + bne clrcachedirty + move.l (SRC)+, BITMASK + cmp.l (CACHE)+, BITMASK + bne clrcachedirty + move.l (SRC)+, BITMASK + cmp.l (CACHE)+, BITMASK + bne clrcachedirty + move.l (SRC)+, BITMASK + cmp.l (CACHE)+, BITMASK + bne clrcachedirty + move.l (SRC)+, BITMASK + cmp.l (CACHE)+, BITMASK + beq clrscanexit +clrcachedirty: + move.l (28+4)(%sp), SRC + move.l (28+8)(%sp), DST + move.l (28+12)(%sp), CACHE + clr.w DATA + clr.w MSBOFFSET + lea pixEven@END.w(%a5), PIXPAIREVENTABLE + lea pixOdd@END.w(%a5), PIXPAIRODDTABLE + move.w #18, HCOUNT + move.w (SRC)+, BITMASK + move.w BITMASK, (CACHE)+ + ror.w #8, BITMASK + add.b BITMASK, BITMASK + scs.b MSBOFFSET + and.b #16, MSBOFFSET +clrscanloop: + lea (PIXPAIREVENTABLE,MSBOFFSET.w), PIXPAIR + move.b BITMASK, DATA + and.b #0x0F, DATA + move.b (PIXPAIR,DATA.w), (DST)+ + lsr.w #2, BITMASK + move.b BITMASK, DATA + and.b #0x0F, DATA + move.b (PIXPAIR,DATA.w), (DST)+ + lsr.w #2, BITMASK + move.b BITMASK, DATA + and.b #0x0F, DATA + move.b (PIXPAIR,DATA.w), (DST)+ + lsr.w #2, BITMASK + move.b BITMASK, DATA + and.b #0x0F, DATA + btst #9, BITMASK + sne.b MSBOFFSET + and.b #16, MSBOFFSET + add.w MSBOFFSET, DATA + add.w MSBOFFSET, DATA + move.b 32(PIXPAIR,DATA.w), (DST)+ + lea (PIXPAIRODDTABLE,MSBOFFSET.w), PIXPAIR + lsr.w #1, BITMASK + move.b BITMASK, DATA + and.b #0x0F, DATA + move.b (PIXPAIR,DATA.w), (DST)+ + lsr.w #2, BITMASK + move.b BITMASK, DATA + and.b #0x0F, DATA + move.b (PIXPAIR,DATA.w), (DST)+ + lsr.w #2, BITMASK + move.b BITMASK, DATA + and.b #0x0F, DATA + move.b (PIXPAIR,DATA.w), (DST)+ + lsr.w #2, BITMASK + move.w (SRC)+, PREFETCH + move.w PREFETCH, (CACHE)+ + ror.w #8, PREFETCH + add.b PREFETCH, PREFETCH + scs.b MSBOFFSET + and.b #16, MSBOFFSET + move.b PREFETCH, DATA + add.b DATA, DATA + and.b #0x0C, DATA + and.b #0x03, BITMASK + or.b BITMASK, DATA + add.w MSBOFFSET, DATA + add.w MSBOFFSET, DATA + move.b 32(PIXPAIR,DATA.w), (DST)+ + lsr.b #1, BITMASK + and.w #1, BITMASK + or.w PREFETCH, BITMASK + dbf.w HCOUNT, clrscanloop + /* + * Last byte doesn't require prefetch. + */ +clrlastword: + lea (PIXPAIREVENTABLE,MSBOFFSET.w), PIXPAIR + move.b BITMASK, DATA + and.b #0x0F, DATA + move.b (PIXPAIR,DATA.w), (DST)+ + lsr.w #2, BITMASK + move.b BITMASK, DATA + and.b #0x0F, DATA + move.b (PIXPAIR,DATA.w), (DST)+ + lsr.w #2, BITMASK + move.b BITMASK, DATA + and.b #0x0F, DATA + move.b (PIXPAIR,DATA.w), (DST)+ + lsr.w #2, BITMASK + move.b BITMASK, DATA + and.b #0x0F, DATA + btst #9, BITMASK + sne.b MSBOFFSET + and.b #16, MSBOFFSET + add.w MSBOFFSET, DATA + add.w MSBOFFSET, DATA + move.b 32(PIXPAIR,DATA.w), (DST)+ + lea (PIXPAIRODDTABLE,MSBOFFSET.w), PIXPAIR + lsr.w #1, BITMASK + move.b BITMASK, DATA + and.b #0x0F, DATA + move.b (PIXPAIR,DATA.w), (DST)+ + lsr.w #2, BITMASK + move.b BITMASK, DATA + and.b #0x0F, DATA + move.b (PIXPAIR,DATA.w), (DST)+ + lsr.w #2, BITMASK + move.b BITMASK, DATA + and.b #0x0F, DATA + move.b (PIXPAIR,DATA.w), (DST)+ + lsr.w #2, BITMASK + and.b #0x03, BITMASK + add.w MSBOFFSET, BITMASK + add.w MSBOFFSET, BITMASK + move.b 32(PIXPAIR,BITMASK.w), (DST) +clrscanexit: + movm.l (%sp)+, #0x5CC8 + rts +.global hrclrUpdateHiresScanline +hrclrUpdateHiresScanline: + movm.l #0x133A, -(%sp) + move.l (28+4)(%sp), SRC + move.l (28+12)(%sp), CACHE + move.l (SRC)+, BITMASK + cmp.l (CACHE)+, BITMASK + bne hrcachedirty + move.l (SRC)+, BITMASK + cmp.l (CACHE)+, BITMASK + bne hrcachedirty + move.l (SRC)+, BITMASK + cmp.l (CACHE)+, BITMASK + bne hrcachedirty + move.l (SRC)+, BITMASK + cmp.l (CACHE)+, BITMASK + bne hrcachedirty + move.l (SRC)+, BITMASK + cmp.l (CACHE)+, BITMASK + bne hrcachedirty + move.l (SRC)+, BITMASK + cmp.l (CACHE)+, BITMASK + bne hrcachedirty + move.l (SRC)+, BITMASK + cmp.l (CACHE)+, BITMASK + bne hrcachedirty + move.l (SRC)+, BITMASK + cmp.l (CACHE)+, BITMASK + bne hrcachedirty + move.l (SRC)+, BITMASK + cmp.l (CACHE)+, BITMASK + bne hrcachedirty + move.l (SRC)+, BITMASK + cmp.l (CACHE)+, BITMASK + beq hrscanexit +hrcachedirty: + move.l (28+4)(%sp), SRC + move.l (28+8)(%sp), DST + move.l (28+12)(%sp), CACHE + clr.w DATA + clr.w MSBOFFSET + lea pixPairEven@END.w(%a5), PIXPAIREVENTABLE + lea pixPairOdd@END.w(%a5), PIXPAIRODDTABLE + move.w #18, HCOUNT + move.w (SRC)+, BITMASK + move.w BITMASK, (CACHE)+ + ror.w #8, BITMASK + add.b BITMASK, BITMASK + scs.b MSBOFFSET + and.b #32, MSBOFFSET +hrscanloop: + lea (PIXPAIREVENTABLE,MSBOFFSET.w), PIXPAIR + move.b BITMASK, DATA + and.b #0x0F, DATA + add.b DATA, DATA + move.w (PIXPAIR,DATA.w), (DST)+ + lsr.w #1, BITMASK + move.b BITMASK, DATA + and.b #0x1E, DATA + move.w (PIXPAIR,DATA.w), (DST)+ + lsr.w #2, BITMASK + move.b BITMASK, DATA + and.b #0x1E, DATA + move.w (PIXPAIR,DATA.w), (DST)+ + lsr.w #3, BITMASK + move.b BITMASK, DATA + and.b #0x0F, DATA + btst #9, BITMASK + sne.b MSBOFFSET + and.b #32, MSBOFFSET + add.w MSBOFFSET, DATA + add.w DATA, DATA + move.w 64(PIXPAIR,DATA.w), (DST)+ + lea (PIXPAIRODDTABLE,MSBOFFSET.w), PIXPAIR + move.b BITMASK, DATA + and.b #0x1E, DATA + move.w (PIXPAIR,DATA.w), (DST)+ + lsr.w #2, BITMASK + move.b BITMASK, DATA + and.b #0x1E, DATA + move.w (PIXPAIR,DATA.w), (DST)+ + lsr.w #2, BITMASK + move.b BITMASK, DATA + and.b #0x1E, DATA + move.w (PIXPAIR,DATA.w), (DST)+ + lsr.w #3, BITMASK + move.w (SRC)+, PREFETCH + move.w PREFETCH, (CACHE)+ + ror.w #8, PREFETCH + add.b PREFETCH, PREFETCH + scs.b MSBOFFSET + and.b #32, MSBOFFSET + move.b PREFETCH, DATA + add.b DATA, DATA + and.b #0x0C, DATA + and.b #0x03, BITMASK + or.b BITMASK, DATA + add.w MSBOFFSET, DATA + add.w DATA, DATA + move.w 64(PIXPAIR,DATA.w), (DST)+ + lsr.b #1, BITMASK + and.w #1, BITMASK + or.w PREFETCH, BITMASK + dbf.w HCOUNT, hrscanloop + /* + * Last byte doesn't require prefetch. + */ +hrlastword: + lea (PIXPAIREVENTABLE,MSBOFFSET.w), PIXPAIR + move.b BITMASK, DATA + and.b #0x0F, DATA + add.b DATA, DATA + move.w (PIXPAIR,DATA.w), (DST)+ + lsr.w #1, BITMASK + move.b BITMASK, DATA + and.b #0x1E, DATA + move.w (PIXPAIR,DATA.w), (DST)+ + lsr.w #2, BITMASK + move.b BITMASK, DATA + and.b #0x1E, DATA + move.w (PIXPAIR,DATA.w), (DST)+ + lsr.w #3, BITMASK + move.b BITMASK, DATA + and.b #0x0F, DATA + btst #9, BITMASK + sne.b MSBOFFSET + and.b #32, MSBOFFSET + add.w MSBOFFSET, DATA + add.w DATA, DATA + move.w 64(PIXPAIR,DATA.w), (DST)+ + lea (PIXPAIRODDTABLE,MSBOFFSET.w), PIXPAIR + move.b BITMASK, DATA + and.b #0x1E, DATA + move.w (PIXPAIR,DATA.w), (DST)+ + lsr.w #2, BITMASK + move.b BITMASK, DATA + and.b #0x1E, DATA + move.w (PIXPAIR,DATA.w), (DST)+ + lsr.w #2, BITMASK + move.b BITMASK, DATA + and.b #0x1E, DATA + move.w (PIXPAIR,DATA.w), (DST)+ + lsr.w #3, BITMASK + and.b #0x03, BITMASK + add.w MSBOFFSET, BITMASK + add.w BITMASK, BITMASK + move.w 64(PIXPAIR,BITMASK.w), (DST) +hrscanexit: + movm.l (%sp)+, #0x5CC8 + rts +/* + * Render double height scanline. + */ +.global hrclrUpdateHiresDblScanline +hrclrUpdateHiresDblScanline: + movm.l #0x133A, -(%sp) + move.l (28+4)(%sp), SRC + move.l (28+12)(%sp), CACHE + move.l (SRC)+, BITMASK + cmp.l (CACHE)+, BITMASK + bne hrcachedirtydbl + move.l (SRC)+, BITMASK + cmp.l (CACHE)+, BITMASK + bne hrcachedirtydbl + move.l (SRC)+, BITMASK + cmp.l (CACHE)+, BITMASK + bne hrcachedirtydbl + move.l (SRC)+, BITMASK + cmp.l (CACHE)+, BITMASK + bne hrcachedirtydbl + move.l (SRC)+, BITMASK + cmp.l (CACHE)+, BITMASK + bne hrcachedirtydbl + move.l (SRC)+, BITMASK + cmp.l (CACHE)+, BITMASK + bne hrcachedirtydbl + move.l (SRC)+, BITMASK + cmp.l (CACHE)+, BITMASK + bne hrcachedirtydbl + move.l (SRC)+, BITMASK + cmp.l (CACHE)+, BITMASK + bne hrcachedirtydbl + move.l (SRC)+, BITMASK + cmp.l (CACHE)+, BITMASK + bne hrcachedirtydbl + move.l (SRC)+, BITMASK + cmp.l (CACHE)+, BITMASK + beq hrscanexitdbl +hrcachedirtydbl: + move.l (28+4)(%sp), SRC + move.l (28+12)(%sp), CACHE + move.l (SRC)+, (CACHE)+ + move.l (SRC)+, (CACHE)+ + move.l (SRC)+, (CACHE)+ + move.l (SRC)+, (CACHE)+ + move.l (SRC)+, (CACHE)+ + move.l (SRC)+, (CACHE)+ + move.l (SRC)+, (CACHE)+ + move.l (SRC)+, (CACHE)+ + move.l (SRC)+, (CACHE)+ + move.l (SRC)+, (CACHE)+ + move.l (28+4)(%sp), SRC + move.l (28+8)(%sp), DST + move.l DST, DSTDBL + add.l #320, DSTDBL + clr.w DATA + clr.w MSBOFFSET + lea pixPairEven@END.w(%a5), PIXPAIREVENTABLE + lea pixPairOdd@END.w(%a5), PIXPAIRODDTABLE + move.w #18, HCOUNT + move.w (SRC)+, BITMASK + ror.w #8, BITMASK + add.b BITMASK, BITMASK + scs.b MSBOFFSET + and.b #32, MSBOFFSET +hrscanloopdbl: + lea (PIXPAIREVENTABLE,MSBOFFSET.w), PIXPAIR + move.b BITMASK, DATA + and.w #0x0F, DATA + add.b DATA, DATA + move.w (PIXPAIR,DATA.w), DATA + move.w DATA, (DST)+ + move.w DATA, (DSTDBL)+ + lsr.w #1, BITMASK + move.b BITMASK, DATA + and.w #0x1E, DATA + move.w (PIXPAIR,DATA.w), DATA + move.w DATA, (DST)+ + move.w DATA, (DSTDBL)+ + lsr.w #2, BITMASK + move.b BITMASK, DATA + and.w #0x1E, DATA + move.w (PIXPAIR,DATA.w), DATA + move.w DATA, (DST)+ + move.w DATA, (DSTDBL)+ + lsr.w #3, BITMASK + move.b BITMASK, DATA + and.w #0x0F, DATA + btst #9, BITMASK + sne.b MSBOFFSET + and.b #32, MSBOFFSET + add.w MSBOFFSET, DATA + add.w DATA, DATA + move.w 64(PIXPAIR,DATA.w), DATA + move.w DATA, (DST)+ + move.w DATA, (DSTDBL)+ + lea (PIXPAIRODDTABLE,MSBOFFSET.w), PIXPAIR + move.b BITMASK, DATA + and.w #0x1E, DATA + move.w (PIXPAIR,DATA.w), DATA + move.w DATA, (DST)+ + move.w DATA, (DSTDBL)+ + lsr.w #2, BITMASK + move.b BITMASK, DATA + and.w #0x1E, DATA + move.w (PIXPAIR,DATA.w), DATA + move.w DATA, (DST)+ + move.w DATA, (DSTDBL)+ + lsr.w #2, BITMASK + move.b BITMASK, DATA + and.w #0x1E, DATA + move.w (PIXPAIR,DATA.w), DATA + move.w DATA, (DST)+ + move.w DATA, (DSTDBL)+ + lsr.w #3, BITMASK + move.w (SRC)+, PREFETCH + ror.w #8, PREFETCH + add.b PREFETCH, PREFETCH + scs.b MSBOFFSET + and.b #32, MSBOFFSET + move.b PREFETCH, DATA + and.w #0x06, DATA + add.b DATA, DATA + and.b #0x03, BITMASK + or.b BITMASK, DATA + add.w MSBOFFSET, DATA + add.w DATA, DATA + move.w 64(PIXPAIR,DATA.w), DATA + move.w DATA, (DST)+ + move.w DATA, (DSTDBL)+ + lsr.b #1, BITMASK + and.w #1, BITMASK + or.w PREFETCH, BITMASK + dbf.w HCOUNT, hrscanloopdbl + /* + * Last byte doesn't require prefetch. + */ +hrlastworddbl: + lea (PIXPAIREVENTABLE,MSBOFFSET.w), PIXPAIR + move.b BITMASK, DATA + and.w #0x0F, DATA + add.b DATA, DATA + move.w (PIXPAIR,DATA.w), DATA + move.w DATA, (DST)+ + move.w DATA, (DSTDBL)+ + lsr.w #1, BITMASK + move.b BITMASK, DATA + and.w #0x1E, DATA + move.w (PIXPAIR,DATA.w), DATA + move.w DATA, (DST)+ + move.w DATA, (DSTDBL)+ + lsr.w #2, BITMASK + move.b BITMASK, DATA + and.w #0x1E, DATA + move.w (PIXPAIR,DATA.w), DATA + move.w DATA, (DST)+ + move.w DATA, (DSTDBL)+ + lsr.w #3, BITMASK + move.b BITMASK, DATA + and.w #0x0F, DATA + btst #9, BITMASK + sne.b MSBOFFSET + and.b #32, MSBOFFSET + add.w MSBOFFSET, DATA + add.w DATA, DATA + move.w 64(PIXPAIR,DATA.w), DATA + move.w DATA, (DST)+ + move.w DATA, (DSTDBL)+ + lea (PIXPAIRODDTABLE,MSBOFFSET.w), PIXPAIR + move.b BITMASK, DATA + and.w #0x1E, DATA + move.w (PIXPAIR,DATA.w), DATA + move.w DATA, (DST)+ + move.w DATA, (DSTDBL)+ + lsr.w #2, BITMASK + move.b BITMASK, DATA + and.w #0x1E, DATA + move.w (PIXPAIR,DATA.w), DATA + move.w DATA, (DST)+ + move.w DATA, (DSTDBL)+ + lsr.w #2, BITMASK + move.b BITMASK, DATA + and.w #0x1E, DATA + move.w (PIXPAIR,DATA.w), DATA + move.w DATA, (DST)+ + move.w DATA, (DSTDBL)+ + lsr.w #3, BITMASK + and.b #0x03, BITMASK + add.w MSBOFFSET, BITMASK + add.w BITMASK, BITMASK + move.w 64(PIXPAIR,BITMASK.w), DATA + move.w DATA, (DST) + move.w DATA, (DSTDBL) +hrscanexitdbl: + movm.l (%sp)+, #0x5CC8 + rts +/* + * Update a row of text. + */ +.global gryUpdateTextRow +gryUpdateTextRow: + movm.l #0x1F3A, -(%sp) + move.l (36+4)(%sp), SRC + move.l (36+8)(%sp), DST + move.l (36+12)(%sp), CACHE + move.w #39, HCOUNT +grycharloop: + clr.w DATA + move.b (SRC)+, DATA + cmp.b (CACHE), DATA + beq.b gryskipchar + move.b DATA, (CACHE)+ + move.w DATA, BITMASK + lsl.w #2, DATA + lsl.w #1, BITMASK + add.w BITMASK, DATA + move.l AppleFont@END.w(%a5), FONT + add.w DATA, FONT + move.w #5, VCOUNT +grycharscanloop: + move.b (FONT)+, (DST) + add.w #40, DST + dbf.w VCOUNT, grycharscanloop + sub.w #(40*6-1), DST + dbf.w HCOUNT, grycharloop + movm.l (%sp)+, #0x5CF8 + rts +gryskipchar: + addq.l #1, CACHE + addq.l #1, DST + dbf.w HCOUNT, grycharloop + movm.l (%sp)+, #0x5CF8 + rts +.global clrUpdateTextRow +clrUpdateTextRow: + movm.l #0x1F3A, -(%sp) + move.l (36+4)(%sp), SRC + move.l (36+8)(%sp), DST + move.l (36+12)(%sp), CACHE + move.w #39, HCOUNT +charloop: + clr.w DATA + move.b (SRC)+, DATA + cmp.b (CACHE), DATA + beq.b skipchar + move.b DATA, (CACHE)+ + move.w DATA, BITMASK + lsl.w #2, DATA + lsl.w #1, BITMASK + add.w BITMASK, DATA + move.l AppleFont@END.w(%a5), FONT + add.w DATA, FONT + move.w #5, VCOUNT +charscanloop: + move.b (FONT)+, BITMASK + lsl.b #4, BITMASK + add.b BITMASK, BITMASK + scs.b DATA + lsl.w #8, DATA + add.b BITMASK, BITMASK + scs.b DATA + move.w DATA, (DST)+ + add.b BITMASK, BITMASK + scs.b DATA + lsl.w #8, DATA + add.b BITMASK, BITMASK + scs.b DATA + move.w DATA, (DST) + add.w #(160-2), DST + dbf.w VCOUNT, charscanloop + sub.w #(160*6-4), DST + dbf.w HCOUNT, charloop + movm.l (%sp)+, #0x5CF8 + rts +skipchar: + addq.l #1, CACHE + addq.l #4, DST + dbf.w HCOUNT, charloop + movm.l (%sp)+, #0x5CF8 + rts +.global hrclrUpdateTextRow +hrclrUpdateTextRow: + movm.l #0x1F3A, -(%sp) + move.l (36+4)(%sp), SRC + move.l (36+8)(%sp), DST + move.l (36+12)(%sp), CACHE + move.w #39, HCOUNT +hrcharloop: + move.b (SRC), DATA + cmp.b (CACHE), DATA + beq.b hrskipchar + move.b DATA, (CACHE)+ + and.b #0xC0, DATA + sne.b BITMASK + move.b BITMASK, DATA + lsl.w #8, DATA + move.b BITMASK, DATA + move.w DATA, (DST)+ + move.w DATA, (DST)+ + move.w DATA, (DST)+ + move.w DATA, (DST) + clr.w DATA + move.b (SRC)+, DATA + lsl.w #3, DATA + move.l AppleFont@END.w(%a5), FONT + add.w DATA, FONT + move.w #7, VCOUNT +hrcharscanloop: + add.w #(320-6), DST + move.b (FONT)+, BITMASK + add.b BITMASK, BITMASK + scs.b DATA + lsl.w #8, DATA + add.b BITMASK, BITMASK + scs.b DATA + move.w DATA, (DST)+ + add.b BITMASK, BITMASK + scs.b DATA + lsl.w #8, DATA + add.b BITMASK, BITMASK + scs.b DATA + move.w DATA, (DST)+ + add.b BITMASK, BITMASK + scs.b DATA + lsl.w #8, DATA + add.b BITMASK, BITMASK + scs.b DATA + move.w DATA, (DST)+ + add.b BITMASK, BITMASK + scs.b DATA + lsl.w #8, DATA + add.b BITMASK, BITMASK + scs.b DATA + move.w DATA, (DST) + dbf.w VCOUNT, hrcharscanloop + sub.w #(320*8-2), DST + dbf.w HCOUNT, hrcharloop + movm.l (%sp)+, #0x5CF8 + rts +hrskipchar: + addq.l #1, SRC + addq.l #1, CACHE + addq.l #8, DST + dbf.w HCOUNT, hrcharloop + movm.l (%sp)+, #0x5CF8 + rts +.global hrclrUpdateDblTextRow +hrclrUpdateDblTextRow: + movm.l #0x1F3A, -(%sp) + move.l (36+4)(%sp), SRC + move.l (36+8)(%sp), DST + move.l (36+12)(%sp), CACHE + move.w #39, HCOUNT +dblcharloop: + move.b (SRC), DATA + cmp.b (CACHE), DATA + beq.b skipdblchar + move.b DATA, (CACHE)+ + and.b #0xC0, DATA + sne.b BITMASK + move.b BITMASK, DATA + lsl.w #8, DATA + move.b BITMASK, DATA + move.w DATA, (DST)+ + move.w DATA, (DST) + addq.l #6, DST + clr.w DATA + move.b (SRC)+, DATA + lsl.w #3, DATA + move.l AppleFont@END.w(%a5), FONT + add.w DATA, FONT + move.w #7, VCOUNT +dblcharscanloop: + add.w #(320-8), DST + move.b (FONT)+, BITMASK + not.b BITMASK + move.b BITMASK, DATA + and.b #0x83, DATA + seq.b (DST)+ + move.b BITMASK, DATA + and.b #0x40, DATA + seq.b (DST)+ + move.b BITMASK, DATA + and.b #0x38, DATA + seq.b (DST)+ + move.b BITMASK, DATA + and.b #0x04, DATA + seq.b (DST) + addq.l #5, DST + dbf.w VCOUNT, dblcharscanloop + sub.w #(320*8), DST + dbf.w HCOUNT, dblcharloop + movm.l (%sp)+, #0x5CF8 + rts +skipdblchar: + addq.l #1, SRC + addq.l #1, CACHE + addq.l #8, DST + dbf.w HCOUNT, dblcharloop + movm.l (%sp)+, #0x5CF8 + rts +/* + * Update a row of lores blocks. + */ +.global hrclrUpdateLoresRow +hrclrUpdateLoresRow: + movm.l #0x1F3A, -(%sp) + move.l (36+4)(%sp), SRC + move.l (36+8)(%sp), DST + move.l (36+12)(%sp), CACHE + lea clr16@END.w(%a5), CLR16BASE + move.w #39, HCOUNT +blockloop: + move.b (SRC), DATA + cmp.b (CACHE), DATA + beq.b skipblock + move.b DATA, (CACHE)+ + andi.w #0x0F, DATA + move.b (CLR16BASE,DATA.w), DATA + move.b DATA, BITMASK + lsl.w #8, DATA + move.b BITMASK, DATA + move.w DATA, BITMASK + swap DATA + move.w BITMASK, DATA + move.w #4, VCOUNT +blockscantoploop: + move.l DATA, (DST)+ + move.l DATA, (DST)+ + add.w #(320-8), DST + dbf.w VCOUNT, blockscantoploop + clr.w DATA + move.b (SRC)+, DATA + lsr.b #4, DATA + move.b (CLR16BASE,DATA.w), DATA + move.b DATA, BITMASK + lsl.w #8, DATA + move.b BITMASK, DATA + move.w DATA, BITMASK + swap DATA + move.w BITMASK, DATA + move.w #3, VCOUNT +blockscanbottomloop: + move.l DATA, (DST)+ + move.l DATA, (DST)+ + add.w #(320-8), DST + dbf.w VCOUNT, blockscanbottomloop + sub.w #(320*9-8), DST + dbf.w HCOUNT, blockloop + movm.l (%sp)+, #0x5CF8 + rts +skipblock: + addq.l #1, SRC + addq.l #1, CACHE + addq.l #8, DST + dbf.w HCOUNT, blockloop + movm.l (%sp)+, #0x5CF8 + rts diff --git a/src/video.c b/src/video.c new file mode 100755 index 0000000..ba6591d --- /dev/null +++ b/src/video.c @@ -0,0 +1,1153 @@ +#include +#include "Apple2.h" + +extern READBYTE *ReadFunction; +extern WRITEBYTE *WriteFunction; +extern UInt8 *AppleMemory; +extern UInt8 *AuxMemory; +extern UInt8 *AppleROM; +extern UInt16 grMode; +extern char *AppleFontBitmap7x8; +extern char *AppleFontBitmap4x6; +void READONLY(UInt16, UInt8); +UInt8 RRMP(UInt16); +#define VIDIMAGE_TEXT 0 +#define VIDIMAGE_LORES_MIX 1 +#define VIDIMAGE_LORES 2 +#define VIDIMAGE_HIRES_MIX 3 +#define VIDIMAGE_HIRES 4 +#define VIDIMAGE_DBLTEXT 5 +VIDIMAGE vidUpdateFuncs[6]; +VIDIMAGE updateVideo; +void gryUpdateText(void); +void gryUpdateHires(void); +void gryUpdateHiresMixed(void); +void clrUpdateText(void); +void clrUpdateHires(void); +void clrUpdateHiresMixed(void); +void hrclrUpdateText(void); +void hrclrUpdateLores(void); +void hrclrUpdateLoresMixed(void); +void hrclrUpdateHires(void); +void hrclrUpdateHiresMixed(void); +void hrclrUpdateDblText(void); +/* + * Variables needed to update the video image. + */ +UInt8 dirtyVideo; +UInt8 *AppleFont = 0; +UInt8 *vidImage; // Destination image bitmap (screen) +UInt16 vidPageOffset; // Source apple memory offset +UInt16 ScanlineOffsetTable[192]; +UInt8 HRMono[256]; +UInt8 *HRMonoLo, *HRMonoHi; +/* + * Use a direct copy of the screen. + */ +UInt8 *vidScreenCache = 0; +#define VID_CACHE_OFFSET(v) ScanlineOffsetTable[v] +#define VID_CACHE_INVALIDATE MemSet(vidScreenCache, 0x2000, 0x69) +void initVideo(void) +{ + WinHandle onScreen; + BitmapType *scanline; + UInt16 i, count; + + dirtyVideo = true; + onScreen = WinGetDisplayWindow(); + scanline = WinGetBitmap(onScreen); + vidImage = (UInt8*) BmpGetBits(scanline); + if (!vidScreenCache) + vidScreenCache = MemPtrNew(0x2000); + if (grMode > GRMODE_COLOR) + { + vidImage += (GRMODE_ISCOLOR(grMode) ? 320 : 40) * 30; + if (!AppleFont) + AppleFont = MemPtrNew(0x100 * 0x08); + MemMove(AppleFont, AppleFontBitmap7x8, 0x40 * 0x08); + MemMove(AppleFont + 0x40 * 0x08, AppleFontBitmap7x8, 0x40 * 0x08); + MemMove(AppleFont + 0x40 * 0x08 * 2, AppleFontBitmap7x8, 0x40 * 0x08); + MemMove(AppleFont + 0x40 * 0x08 * 3, AppleFontBitmap7x8, 0x20 * 0x08); + MemMove(AppleFont + 0x40 * 0x08 * 3 + 0x20 * 0x08, AppleFontBitmap7x8 + 0x40 * 0x08, 0x20 * 0x08); + for (count = 0x80 * 0x08; count < (0x100 * 0x08); count++) AppleFont[count] = ~AppleFont[count]; + vidUpdateFuncs[VIDIMAGE_TEXT] = hrclrUpdateText; + vidUpdateFuncs[VIDIMAGE_LORES] = hrclrUpdateLores; + vidUpdateFuncs[VIDIMAGE_LORES_MIX] = hrclrUpdateLoresMixed; + vidUpdateFuncs[VIDIMAGE_HIRES] = hrclrUpdateHires; + vidUpdateFuncs[VIDIMAGE_HIRES_MIX] = hrclrUpdateHiresMixed; + vidUpdateFuncs[VIDIMAGE_DBLTEXT] = hrclrUpdateDblText; + } + else + { + if (!AppleFont) + AppleFont = MemPtrNew(0x100 * 0x06); + MemMove(AppleFont, AppleFontBitmap4x6, 0x40 * 0x06); + MemMove(AppleFont + 0x40 * 0x06, AppleFontBitmap4x6, 0x40 * 0x06); + MemMove(AppleFont + 0x40 * 0x06 * 2, AppleFontBitmap4x6, 0x40 * 0x06); + MemMove(AppleFont + 0x40 * 0x06 * 3, AppleFontBitmap4x6, 0x20 * 0x06); + MemMove(AppleFont + 0x40 * 0x06 * 3 + 0x20 * 0x06, AppleFontBitmap4x6 + 0x40 * 0x06, 0x20 * 0x06); + if (grMode == GRMODE_COLOR) + { + vidImage += 160 * 15; + /* + * Invert font data. + */ + for (count = 0x80 * 0x06; count < (0x100 * 0x06); count++) + AppleFont[count] = ~AppleFont[count]; + vidUpdateFuncs[VIDIMAGE_TEXT] = clrUpdateText; + vidUpdateFuncs[VIDIMAGE_LORES_MIX] = clrUpdateText; + vidUpdateFuncs[VIDIMAGE_LORES] = clrUpdateText; + vidUpdateFuncs[VIDIMAGE_HIRES] = clrUpdateHires; + vidUpdateFuncs[VIDIMAGE_HIRES_MIX] = clrUpdateHiresMixed; + vidUpdateFuncs[VIDIMAGE_DBLTEXT] = clrUpdateText; + } + else + { + vidImage += 40 * 15; + /* + * Expand font data. + */ + for (count = 0x80 * 0x06; count < (0x100 * 0x06); count++) + { + AppleFont[count] = (((AppleFont[count] & 0x01) ? 0x00 : 0x03) + | ((AppleFont[count] & 0x02) ? 0x00 : 0x0C) + | ((AppleFont[count] & 0x04) ? 0x00 : 0x30) + | ((AppleFont[count] & 0x08) ? 0x00 : 0xC0)); + } + /* + * Create Hires->Mono conversion table. + */ + HRMonoLo = HRMono; + HRMonoHi = HRMono + 128; + for (count = 0; count < 0x80; count++) + { + HRMonoLo[count] = ((count & 0x40 ? 0 : 0x02) + | (count & 0x20 ? 0 : 0x04) + | (count & 0x10 ? 0 : 0x08) + | (count & 0x08 ? 0 : 0x10) + | (count & 0x04 ? 0 : 0x20) + | (count & 0x02 ? 0 : 0x40) + | (count & 0x01 ? 0 : 0x80)); + HRMonoHi[count] = ((count & 0x40 ? 0 : 0x01) + | (count & 0x20 ? 0 : 0x02) + | (count & 0x10 ? 0 : 0x04) + | (count & 0x08 ? 0 : 0x08) + | (count & 0x04 ? 0 : 0x10) + | (count & 0x02 ? 0 : 0x20) + | (count & 0x01 ? 0 : 0x40)); + } + vidUpdateFuncs[VIDIMAGE_TEXT] = gryUpdateText; + vidUpdateFuncs[VIDIMAGE_LORES_MIX] = gryUpdateText; + vidUpdateFuncs[VIDIMAGE_LORES] = gryUpdateText; + vidUpdateFuncs[VIDIMAGE_HIRES] = gryUpdateHires; + vidUpdateFuncs[VIDIMAGE_HIRES_MIX] = gryUpdateHiresMixed; + vidUpdateFuncs[VIDIMAGE_DBLTEXT] = gryUpdateText; + } + } + /* + * Create offset table for rendering video image top->down. + */ + for (i = 0;i < 192;i++) + ScanlineOffsetTable[i] = (i & 7) * 0x400 + ((i >> 3) & 7) * 0x80 + (i >> 6) * 0x28; + setVideoFuncs(true); +} + +/****************************************************************\ +* * +* Video mode state * +* * +\****************************************************************/ + +void clrVidFuncs(UInt16 vidBits) +{ + UInt16 page; + + if (!SS_ISSET(vidBits, SS_TEXT) && SS_ISSET(vidBits, SS_HIRES)) + { + if (SS_ISSET(vidBits, SS_PAGE2)) + for (page = 0x40; page < 0x60; page++) + WriteFunction[page] = NULL; + else + for (page = 0x20; page < 0x40; page++) + WriteFunction[page] = NULL; + } + else + { + if (SS_ISSET(vidBits, SS_PAGE2) && !SS_ISSET(vidBits, SS_80STORE)) + { + WriteFunction[0x08] = NULL; + WriteFunction[0x09] = NULL; + WriteFunction[0x0A] = NULL; + WriteFunction[0x0B] = NULL; + } + else + { + WriteFunction[0x04] = NULL; + WriteFunction[0x05] = NULL; + WriteFunction[0x06] = NULL; + WriteFunction[0x07] = NULL; + ReadFunction[0x04] = NULL; + ReadFunction[0x05] = NULL; + ReadFunction[0x06] = NULL; + ReadFunction[0x07] = NULL; + } + } +} +/* Screen Write */ +void WTXTM(UInt16, UInt8); +void WATXTM(UInt16, UInt8); +UInt8 RATXTM(UInt16 address); +void awrap_AuxTxtMemReadWrite(void) +{ + asm(".global WTXTM"); + asm(".global WATXTM"); + asm(".global RATXTM"); + asm("WTXTM:"); + asm("move.b %d0, (%a2,%d6.l)"); + asm("move.b #1, dirtyVideo@END.w(%a5)"); + asm("rts"); + asm("WATXTM:"); + asm("move.l AuxMemory@END.w(%a5), %a6"); + asm("add.l #(16384-0x400), %a6"); + asm("move.b %d0, (%a6, %d6.l)"); + asm("move.b #1, dirtyVideo@END.w(%a5)"); + asm("rts"); + asm("RATXTM:"); + asm("move.l AuxMemory@END.w(%a5), %a6"); + asm("add.l #(16384-0x400), %a6"); + asm("clr.l %d0"); + asm("move.b (%a6, %d6.l), %d0"); + asm("rts"); +} +WRMEM_CWRAP(WSCM, address, data) +{ + UInt16 page; + + dirtyVideo = 2; // Add call to setVideoFuncs at next VideoUpdate + AppleMemory[address] = data; + /* + * Once dirtyVideo is set, no need to slow down the rest. + */ + clrVidFuncs(vidIOU); +} +/* + * Set the updateVideo function based on all the settings. + * This is incomplete - missing lo-res checking. + */ +void setVideoFuncs(Boolean invalidate_cache) +{ + UInt16 page; + + if (invalidate_cache) + { + VID_CACHE_INVALIDATE; + } + if (!SS_ISSET(memIOU, SS_RAMWRT)) + { + if (SS_ISSET(vidIOU, SS_TEXT)) + { + updateVideo = vidUpdateFuncs[SS_ISSET(vidIOU, SS_80VID) ? VIDIMAGE_DBLTEXT : VIDIMAGE_TEXT]; + if (SS_ISSET(vidIOU, SS_PAGE2)) + { + if (SS_ISSET(vidIOU, SS_80STORE)) + { + vidPageOffset = 0x0400; + if ((grMode > GRMODE_COLOR) && prefs.enable80Col) + { + WriteFunction[0x04] = WATXTM; + WriteFunction[0x05] = WATXTM; + WriteFunction[0x06] = WATXTM; + WriteFunction[0x07] = WATXTM; + ReadFunction[0x04] = RATXTM; + ReadFunction[0x05] = RATXTM; + ReadFunction[0x06] = RATXTM; + ReadFunction[0x07] = RATXTM; + } + else + { + WriteFunction[0x04] = READONLY; + WriteFunction[0x05] = READONLY; + WriteFunction[0x06] = READONLY; + WriteFunction[0x07] = READONLY; + } + } + else + { + vidPageOffset = 0x0800; + WriteFunction[0x08] = WTXTM; + WriteFunction[0x09] = WTXTM; + WriteFunction[0x0A] = WTXTM; + WriteFunction[0x0B] = WTXTM; + } + } + else + { + vidPageOffset = 0x0400; + WriteFunction[0x04] = WTXTM; + WriteFunction[0x05] = WTXTM; + WriteFunction[0x06] = WTXTM; + WriteFunction[0x07] = WTXTM; + } + } + else if (SS_ISSET(vidIOU, SS_HIRES)) + { + if (SS_ISSET(vidIOU, SS_PAGE2)) + { + vidPageOffset = 0x4000; + for (page = 0x40; page < 0x60; page++) + WriteFunction[page] = WSCM; + if (SS_ISSET(vidIOU, SS_MIXED)) + { + updateVideo = vidUpdateFuncs[VIDIMAGE_HIRES_MIX]; + WriteFunction[0x04] = NULL; + WriteFunction[0x05] = NULL; + WriteFunction[0x06] = NULL; + WriteFunction[0x07] = NULL; + WriteFunction[0x08] = WSCM; + WriteFunction[0x09] = WSCM; + WriteFunction[0x0A] = WSCM; + WriteFunction[0x0B] = WSCM; + } + else + updateVideo = vidUpdateFuncs[VIDIMAGE_HIRES]; + } + else + { + vidPageOffset = 0x2000; + for (page = 0x20; page < 0x40; page++) + WriteFunction[page] = WSCM; + if (SS_ISSET(vidIOU, SS_MIXED)) + { + updateVideo = vidUpdateFuncs[VIDIMAGE_HIRES_MIX]; + WriteFunction[0x04] = WSCM; + WriteFunction[0x05] = WSCM; + WriteFunction[0x06] = WSCM; + WriteFunction[0x07] = WSCM; + WriteFunction[0x08] = NULL; + WriteFunction[0x09] = NULL; + WriteFunction[0x0A] = NULL; + WriteFunction[0x0B] = NULL; + } + else + updateVideo = vidUpdateFuncs[VIDIMAGE_HIRES]; + } + } + else + { + if (SS_ISSET(vidIOU, SS_PAGE2)) + { + vidPageOffset = 0x0800; + updateVideo = SS_ISSET(vidIOU, SS_MIXED) ? vidUpdateFuncs[VIDIMAGE_LORES_MIX] : vidUpdateFuncs[VIDIMAGE_LORES]; + WriteFunction[0x08] = WSCM; + WriteFunction[0x09] = WSCM; + WriteFunction[0x0A] = WSCM; + WriteFunction[0x0B] = WSCM; + } + else + { + vidPageOffset = 0x0400; + updateVideo = SS_ISSET(vidIOU, SS_MIXED) ? vidUpdateFuncs[VIDIMAGE_LORES_MIX] : vidUpdateFuncs[VIDIMAGE_LORES]; + WriteFunction[0x04] = WSCM; + WriteFunction[0x05] = WSCM; + WriteFunction[0x06] = WSCM; + WriteFunction[0x07] = WSCM; + } + } + } +} +void toggleVideoSoftSwitch(UInt8 io) +{ + UInt16 dirty, page; + Boolean invalidate = false; + + dirty = vidIOU; + switch (io) + { + case 0x00: // Text -> Graphics + if (SS_ISSET(vidIOU, SS_TEXT)) + invalidate = true; + SS_RESET(vidIOU, SS_TEXT); + break; + case 0x01: // Graphics -> Text + if (!SS_ISSET(vidIOU, SS_TEXT)) + invalidate = true; + SS_SET(vidIOU, SS_TEXT); + break; + case 0x02: // Full Screen + if (SS_ISSET(vidIOU, SS_MIXED)) + invalidate = true; + SS_RESET(vidIOU, SS_MIXED); + break; + case 0x03: // Mixed Screen + if (!SS_ISSET(vidIOU, SS_MIXED)) + invalidate = true; + SS_SET(vidIOU, SS_MIXED); + break; + case 0x04: // page 1 + SS_RESET(vidIOU, SS_PAGE2); + break; + case 0x05: // page 2 + SS_SET(vidIOU, SS_PAGE2); + break; + case 0x06: // HiRes -> Text/LoRes + if (SS_ISSET(vidIOU, SS_HIRES)) + invalidate = true; + SS_RESET(vidIOU, SS_HIRES); + break; + case 0x07: // Text/LoRes -> HiRes + if (!SS_ISSET(vidIOU, SS_HIRES)) + invalidate = true; + SS_SET(vidIOU, SS_HIRES); + break; + } + if (dirty != vidIOU) + { + dirtyVideo = true; + clrVidFuncs(dirty); + setVideoFuncs(invalidate); + if (!SS_ISSET(vidIOU, SS_TEXT) && SS_ISSET((dirty ^ vidIOU), SS_PAGE2)) + { + AppleInstrCount += AppleInstrInc - state6502.LongRegs.INST; + state6502.LongRegs.INST = 0; // Keep frequent screen updates from holding off user input. + } + } +} + +/****************************************************************\ +* * +* Video update routines * +* * +\****************************************************************/ + +#define PALM_CLR_WHITE 0 +#define PALM_CLR_BLACK 255 +#define PALM_CLR_GREEN 210 +#define PALM_CLR_VIOLET 17 +#define PALM_CLR_PURPLE 17 +#define PALM_CLR_RED 125 +#define PALM_CLR_BLUE 107 +#define PALM_CLR_DRKRED (8*16+9) +#define PALM_CLR_DRKBLUE (12*16+11) +#define PALM_CLR_DRKGREEN (13*16+4) +#define PALM_CLR_DRKGREY (13*16+11) +#define PALM_CLR_CYAN (4*16+4) +#define PALM_CLR_BROWN (8*16+7) +#define PALM_CLR_ORANGE (7*16+5) +#define PALM_CLR_LTGREY (13*16+14) +#define PALM_CLR_PINK 2 +#define PALM_CLR_YELLOW 108 +#define PALM_CLR_AQUA (5*16+10) +#define PALM_CLR_GREY (13*16+12) +/* + * 16 color table. + */ +UInt8 clr16[16] = +{ + PALM_CLR_BLACK, + PALM_CLR_DRKRED, + PALM_CLR_DRKBLUE, + PALM_CLR_VIOLET, + PALM_CLR_DRKGREEN, + PALM_CLR_DRKGREY, + PALM_CLR_BLUE, + PALM_CLR_CYAN, + PALM_CLR_BROWN, + PALM_CLR_ORANGE, + PALM_CLR_LTGREY, + PALM_CLR_PINK, + PALM_CLR_GREEN, + PALM_CLR_YELLOW, + PALM_CLR_AQUA, + PALM_CLR_WHITE +}; +/* + * Color array for standard res device. + */ +UInt8 pixEven[96] = +{ + /* + * 0 MSB. + */ + PALM_CLR_BLACK , + PALM_CLR_BLACK , + PALM_CLR_VIOLET, + PALM_CLR_GREY, + PALM_CLR_GREEN , + PALM_CLR_GREEN , + PALM_CLR_WHITE , + PALM_CLR_WHITE , + PALM_CLR_BLACK , + PALM_CLR_BLACK , + PALM_CLR_VIOLET, + PALM_CLR_GREY, + PALM_CLR_GREY, + PALM_CLR_GREY, + PALM_CLR_WHITE , + PALM_CLR_WHITE , + /* + * 1 MSB. + */ + PALM_CLR_BLACK , + PALM_CLR_BLACK , + PALM_CLR_BLUE , + PALM_CLR_GREY, + PALM_CLR_RED , + PALM_CLR_RED , + PALM_CLR_WHITE , + PALM_CLR_WHITE , + PALM_CLR_BLACK , + PALM_CLR_BLACK , + PALM_CLR_BLUE , + PALM_CLR_GREY, + PALM_CLR_GREY, + PALM_CLR_GREY, + PALM_CLR_WHITE , + PALM_CLR_WHITE , + /* + * These values are for the even->odd byte transition. + * Even 0 MSB -> Odd 0 MSB. + */ + PALM_CLR_BLACK , + PALM_CLR_BLACK , + PALM_CLR_VIOLET, + PALM_CLR_GREY, + PALM_CLR_GREEN , + PALM_CLR_GREEN , + PALM_CLR_WHITE , + PALM_CLR_WHITE , + PALM_CLR_BLACK , + PALM_CLR_BLACK , + PALM_CLR_VIOLET, + PALM_CLR_GREY, + PALM_CLR_GREY, + PALM_CLR_GREY, + PALM_CLR_WHITE , + PALM_CLR_WHITE , + /* + * These values are for the even->odd byte transition. + * Even 1 MSB -> Odd 0 MSB. + */ + PALM_CLR_BLACK , + PALM_CLR_BLACK , + PALM_CLR_BLUE , + PALM_CLR_GREY, + PALM_CLR_GREEN , + PALM_CLR_GREEN , + PALM_CLR_WHITE , + PALM_CLR_WHITE , + PALM_CLR_BLACK , + PALM_CLR_BLACK , + PALM_CLR_BLUE , + PALM_CLR_GREY, + PALM_CLR_GREY, + PALM_CLR_GREY, + PALM_CLR_WHITE , + PALM_CLR_WHITE , + /* + * These values are for the even->odd byte transition. + * Even 0 MSB -> Odd 1 MSB. + */ + PALM_CLR_BLACK , + PALM_CLR_BLACK , + PALM_CLR_VIOLET, + PALM_CLR_GREY, + PALM_CLR_RED , + PALM_CLR_RED , + PALM_CLR_WHITE , + PALM_CLR_WHITE , + PALM_CLR_BLACK , + PALM_CLR_BLACK , + PALM_CLR_VIOLET, + PALM_CLR_GREY, + PALM_CLR_GREY, + PALM_CLR_GREY, + PALM_CLR_WHITE , + PALM_CLR_WHITE , + /* + * These values are for the even->odd byte transition. + * Even 1 MSB -> Odd 1 MSB. + */ + PALM_CLR_BLACK , + PALM_CLR_BLACK , + PALM_CLR_BLUE , + PALM_CLR_GREY, + PALM_CLR_RED , + PALM_CLR_RED , + PALM_CLR_WHITE , + PALM_CLR_WHITE , + PALM_CLR_BLACK , + PALM_CLR_BLACK , + PALM_CLR_BLUE , + PALM_CLR_GREY, + PALM_CLR_GREY, + PALM_CLR_GREY, + PALM_CLR_WHITE , + PALM_CLR_WHITE +}; +UInt8 pixOdd[96] = +{ + /* + * 0 MSB. + */ + PALM_CLR_BLACK , + PALM_CLR_BLACK , + PALM_CLR_GREEN , + PALM_CLR_GREY, + PALM_CLR_VIOLET, + PALM_CLR_VIOLET, + PALM_CLR_WHITE , + PALM_CLR_WHITE , + PALM_CLR_BLACK , + PALM_CLR_BLACK , + PALM_CLR_GREEN , + PALM_CLR_GREY, + PALM_CLR_GREY, + PALM_CLR_GREY, + PALM_CLR_WHITE , + PALM_CLR_WHITE , + /* + * 1 MSB. + */ + PALM_CLR_BLACK , + PALM_CLR_BLACK , + PALM_CLR_RED , + PALM_CLR_GREY, + PALM_CLR_BLUE , + PALM_CLR_BLUE , + PALM_CLR_WHITE , + PALM_CLR_WHITE , + PALM_CLR_BLACK , + PALM_CLR_BLACK , + PALM_CLR_RED , + PALM_CLR_GREY, + PALM_CLR_GREY, + PALM_CLR_GREY, + PALM_CLR_WHITE , + PALM_CLR_WHITE , + /* + * These values are for the even->odd byte transition. + * Odd 0 MSB -> Even 0 MSB. + */ + PALM_CLR_BLACK , + PALM_CLR_BLACK , + PALM_CLR_GREEN , + PALM_CLR_GREY, + PALM_CLR_VIOLET, + PALM_CLR_VIOLET, + PALM_CLR_WHITE , + PALM_CLR_WHITE , + PALM_CLR_BLACK , + PALM_CLR_BLACK , + PALM_CLR_GREEN , + PALM_CLR_GREY, + PALM_CLR_GREY, + PALM_CLR_GREY, + PALM_CLR_WHITE , + PALM_CLR_WHITE , + /* + * These values are for the even->odd byte transition. + * Odd 1 MSB -> Even 0 MSB. + */ + PALM_CLR_BLACK , + PALM_CLR_BLACK , + PALM_CLR_RED , + PALM_CLR_GREY, + PALM_CLR_VIOLET, + PALM_CLR_VIOLET, + PALM_CLR_WHITE , + PALM_CLR_WHITE , + PALM_CLR_BLACK , + PALM_CLR_BLACK , + PALM_CLR_RED , + PALM_CLR_GREY, + PALM_CLR_GREY, + PALM_CLR_GREY, + PALM_CLR_WHITE , + PALM_CLR_WHITE , + /* + * These values are for the even->odd byte transition. + * Odd 0 MSB -> Even 1 MSB. + */ + PALM_CLR_BLACK , + PALM_CLR_BLACK , + PALM_CLR_GREEN , + PALM_CLR_GREY, + PALM_CLR_BLUE , + PALM_CLR_BLUE , + PALM_CLR_WHITE , + PALM_CLR_WHITE , + PALM_CLR_BLACK , + PALM_CLR_BLACK , + PALM_CLR_GREEN , + PALM_CLR_GREY, + PALM_CLR_GREY, + PALM_CLR_GREY, + PALM_CLR_WHITE , + PALM_CLR_WHITE , + /* + * These values are for the even->odd byte transition. + * Odd 1 MSB -> Even 1 MSB. + */ + PALM_CLR_BLACK , + PALM_CLR_BLACK , + PALM_CLR_RED , + PALM_CLR_GREY, + PALM_CLR_BLUE , + PALM_CLR_BLUE , + PALM_CLR_WHITE , + PALM_CLR_WHITE , + PALM_CLR_BLACK , + PALM_CLR_BLACK , + PALM_CLR_RED , + PALM_CLR_GREY, + PALM_CLR_GREY, + PALM_CLR_GREY, + PALM_CLR_WHITE , + PALM_CLR_WHITE +}; +/* + * Color interpolation arrays. + */ +#define CLR_PAIR(c1,c2) (((PALM_CLR_##c1)<<8)|(PALM_CLR_##c2)) +/* + * Interpolated colors (sold fill). + */ +UInt16 pixPairEven[96] = +{ + /* + * 0 MSB. + */ + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(VIOLET, VIOLET), + CLR_PAIR(WHITE , BLACK ), + CLR_PAIR(GREEN , GREEN ), + CLR_PAIR(GREEN , GREEN ), + CLR_PAIR(WHITE , WHITE ), + CLR_PAIR(WHITE , WHITE ), + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(VIOLET, VIOLET), + CLR_PAIR(WHITE , BLACK ), + CLR_PAIR(BLACK , WHITE ), + CLR_PAIR(BLACK , WHITE ), + CLR_PAIR(WHITE , WHITE ), + CLR_PAIR(WHITE , WHITE ), + /* + * 1 MSB. + */ + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(BLUE , BLUE ), + CLR_PAIR(WHITE , BLACK ), + CLR_PAIR(RED , RED ), + CLR_PAIR(RED , RED ), + CLR_PAIR(WHITE , WHITE ), + CLR_PAIR(WHITE , WHITE ), + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(BLUE , BLUE ), + CLR_PAIR(WHITE , BLACK ), + CLR_PAIR(BLACK , WHITE ), + CLR_PAIR(BLACK , WHITE ), + CLR_PAIR(WHITE , WHITE ), + CLR_PAIR(WHITE , WHITE ), + /* + * These values are for the even->odd byte transition. + * Even 0 MSB -> Odd 0 MSB. + */ + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(VIOLET, VIOLET), + CLR_PAIR(WHITE , BLACK ), + CLR_PAIR(GREEN , GREEN ), + CLR_PAIR(GREEN , GREEN ), + CLR_PAIR(WHITE , WHITE ), + CLR_PAIR(WHITE , WHITE ), + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(VIOLET, VIOLET), + CLR_PAIR(WHITE , BLACK ), + CLR_PAIR(BLACK , WHITE ), + CLR_PAIR(BLACK , WHITE ), + CLR_PAIR(WHITE , WHITE ), + CLR_PAIR(WHITE , WHITE ), + /* + * These values are for the even->odd byte transition. + * Even 1 MSB -> Odd 0 MSB. + */ + CLR_PAIR(BLACK , BLACK), + CLR_PAIR(BLACK , BLACK), + CLR_PAIR(BLUE , BLUE ), + CLR_PAIR(WHITE , BLACK), + CLR_PAIR(GREEN , GREEN), + CLR_PAIR(GREEN , GREEN), + CLR_PAIR(WHITE , WHITE), + CLR_PAIR(WHITE , WHITE), + CLR_PAIR(BLACK , BLACK), + CLR_PAIR(BLACK , BLACK), + CLR_PAIR(BLUE, BLUE ), + CLR_PAIR(WHITE , BLACK), + CLR_PAIR(BLACK , WHITE), + CLR_PAIR(BLACK , WHITE), + CLR_PAIR(WHITE , WHITE), + CLR_PAIR(WHITE , WHITE), + /* + * These values are for the even->odd byte transition. + * Even 0 MSB -> Odd 1 MSB. + */ + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(VIOLET, VIOLET), + CLR_PAIR(WHITE , BLACK ), + CLR_PAIR(RED , RED ), + CLR_PAIR(RED , RED ), + CLR_PAIR(WHITE , WHITE ), + CLR_PAIR(WHITE , WHITE ), + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(VIOLET, VIOLET), + CLR_PAIR(WHITE , BLACK ), + CLR_PAIR(BLACK , WHITE ), + CLR_PAIR(BLACK , WHITE ), + CLR_PAIR(WHITE , WHITE ), + CLR_PAIR(WHITE , WHITE ), + /* + * These values are for the even->odd byte transition. + * Even 1 MSB -> Odd 1 MSB. + */ + CLR_PAIR(BLACK , BLACK), + CLR_PAIR(BLACK , BLACK), + CLR_PAIR(BLUE , BLUE ), + CLR_PAIR(WHITE , BLACK), + CLR_PAIR(RED , RED ), + CLR_PAIR(RED , RED ), + CLR_PAIR(WHITE , WHITE), + CLR_PAIR(WHITE , WHITE), + CLR_PAIR(BLACK , BLACK), + CLR_PAIR(BLACK , BLACK), + CLR_PAIR(BLUE , BLUE ), + CLR_PAIR(WHITE , BLACK), + CLR_PAIR(BLACK , WHITE), + CLR_PAIR(BLACK , WHITE), + CLR_PAIR(WHITE , WHITE), + CLR_PAIR(WHITE , WHITE) +}; +UInt16 pixPairOdd[96] = +{ + /* + * 0 MSB. + */ + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(GREEN , GREEN ), + CLR_PAIR(WHITE , BLACK ), + CLR_PAIR(VIOLET, VIOLET), + CLR_PAIR(VIOLET, VIOLET), + CLR_PAIR(WHITE , WHITE ), + CLR_PAIR(WHITE , WHITE ), + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(GREEN , GREEN ), + CLR_PAIR(WHITE , BLACK ), + CLR_PAIR(BLACK , WHITE ), + CLR_PAIR(BLACK , WHITE ), + CLR_PAIR(WHITE , WHITE ), + CLR_PAIR(WHITE , WHITE ), + /* + * 1 MSB. + */ + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(RED , RED ), + CLR_PAIR(WHITE , BLACK ), + CLR_PAIR(BLUE , BLUE ), + CLR_PAIR(BLUE , BLUE ), + CLR_PAIR(WHITE , WHITE ), + CLR_PAIR(WHITE , WHITE ), + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(RED , RED ), + CLR_PAIR(WHITE , BLACK ), + CLR_PAIR(BLACK , WHITE ), + CLR_PAIR(BLACK , WHITE ), + CLR_PAIR(WHITE , WHITE ), + CLR_PAIR(WHITE , WHITE ), + /* + * These values are for the even->odd byte transition. + * Odd 0 MSB -> Even 0 MSB. + */ + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(GREEN, GREEN ), + CLR_PAIR(WHITE , BLACK ), + CLR_PAIR(VIOLET, VIOLET), + CLR_PAIR(VIOLET, VIOLET), + CLR_PAIR(WHITE , WHITE ), + CLR_PAIR(WHITE , WHITE ), + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(GREEN , GREEN ), + CLR_PAIR(WHITE , BLACK ), + CLR_PAIR(BLACK , WHITE ), + CLR_PAIR(BLACK , WHITE ), + CLR_PAIR(WHITE , WHITE ), + CLR_PAIR(WHITE , WHITE ), + /* + * These values are for the even->odd byte transition. + * Odd 1 MSB -> Even 0 MSB. + */ + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(RED , RED ), + CLR_PAIR(WHITE , BLACK ), + CLR_PAIR(VIOLET, VIOLET), + CLR_PAIR(VIOLET, VIOLET), + CLR_PAIR(WHITE , WHITE ), + CLR_PAIR(WHITE , WHITE ), + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(BLACK , BLACK ), + CLR_PAIR(RED , RED ), + CLR_PAIR(WHITE , BLACK ), + CLR_PAIR(BLACK , WHITE ), + CLR_PAIR(BLACK , WHITE ), + CLR_PAIR(WHITE , WHITE ), + CLR_PAIR(WHITE , WHITE ), + /* + * These values are for the even->odd byte transition. + * Odd 0 MSB -> Even 1 MSB. + */ + CLR_PAIR(BLACK , BLACK), + CLR_PAIR(BLACK , BLACK), + CLR_PAIR(GREEN , GREEN), + CLR_PAIR(WHITE , BLACK), + CLR_PAIR(BLUE , BLUE ), + CLR_PAIR(BLUE , BLUE ), + CLR_PAIR(WHITE , WHITE), + CLR_PAIR(WHITE , WHITE), + CLR_PAIR(BLACK , BLACK), + CLR_PAIR(BLACK , BLACK), + CLR_PAIR(GREEN , GREEN), + CLR_PAIR(WHITE , BLACK), + CLR_PAIR(BLACK , WHITE), + CLR_PAIR(BLACK , WHITE), + CLR_PAIR(WHITE , WHITE), + CLR_PAIR(WHITE , WHITE), + /* + * These values are for the even->odd byte transition. + * Odd 1 MSB -> Even 1 MSB. + */ + CLR_PAIR(BLACK , BLACK), + CLR_PAIR(BLACK , BLACK), + CLR_PAIR(RED , RED ), + CLR_PAIR(WHITE , BLACK), + CLR_PAIR(BLUE , BLUE ), + CLR_PAIR(BLUE , BLUE ), + CLR_PAIR(WHITE , WHITE), + CLR_PAIR(WHITE , WHITE), + CLR_PAIR(BLACK , BLACK), + CLR_PAIR(BLACK , BLACK), + CLR_PAIR(RED , RED ), + CLR_PAIR(WHITE , BLACK), + CLR_PAIR(BLACK , WHITE), + CLR_PAIR(BLACK , WHITE), + CLR_PAIR(WHITE , WHITE), + CLR_PAIR(WHITE , WHITE) +}; +typedef void (*pfnVidUpdateSection)(UInt8 *, UInt8 *, UInt8 *); +void gryUpdateTextRow(UInt8 *, UInt8 *, UInt8 *); +void clrUpdateTextRow(UInt8 *, UInt8 *, UInt8 *); +void gryUpdateHiresScanline(UInt8 *, UInt8 *, UInt8 *); +void clrUpdateHiresScanline(UInt8 *, UInt8 *, UInt8 *); +void defUpdateText(pfnVidUpdateSection pfnText, UInt16 pitch) +{ + Int16 vert; + UInt8 *_pointer = vidImage; + dirtyVideo = false; + for (vert = 0; vert < 192; vert += 8) + { + pfnText(&AppleMemory[ScanlineOffsetTable[vert] + vidPageOffset], _pointer, &vidScreenCache[VID_CACHE_OFFSET(vert)]); + _pointer += pitch * 6; + } +} +void gryUpdateText(void) +{ + defUpdateText(gryUpdateTextRow, 40); +} +void clrUpdateText(void) +{ + defUpdateText(clrUpdateTextRow, 160); +} +void defUpdateHires(pfnVidUpdateSection pfnHires, UInt16 pitch) +{ + Int16 hori, vert; + UInt16 biteven, bitodd; + UInt8 *_pointer = vidImage; + dirtyVideo = false; + for (vert = 0; vert < 192; vert++) + { + if ((vert & 0x03) == 0x01) + { + UInt32 shrinkScans[10], *scanptr, *nextscanptr; + scanptr = (UInt32 *)&AppleMemory[ScanlineOffsetTable[vert] + vidPageOffset]; + nextscanptr = (UInt32 *)&AppleMemory[ScanlineOffsetTable[++vert] + vidPageOffset]; + for (hori = 0; hori < 10; hori++) + shrinkScans[hori] = *scanptr++ | *nextscanptr++; + pfnHires((UInt8 *)&shrinkScans, _pointer, &vidScreenCache[VID_CACHE_OFFSET(vert)]); + } + else + { + pfnHires(&AppleMemory[ScanlineOffsetTable[vert] + vidPageOffset], _pointer, &vidScreenCache[VID_CACHE_OFFSET(vert)]); + } + _pointer += pitch; + } +} +void gryUpdateHires(void) +{ + defUpdateHires(gryUpdateHiresScanline, 40); +} +void clrUpdateHires(void) +{ + defUpdateHires(clrUpdateHiresScanline, 160); +} +void defUpdateHiresMixed(pfnVidUpdateSection pfnHires, pfnVidUpdateSection pfnText, UInt16 pitch) +{ + Int16 hori, vert, textpage; + UInt16 scanaddr, chary, biteven, bitodd; + UInt8 *_pointer = vidImage; + dirtyVideo = false; + for (vert = 0; vert < 160/*144*/; vert++) + { + if ((vert & 0x03) == 0x01) + { + UInt32 shrinkScans[10], *scanptr, *nextscanptr; + scanptr = (UInt32 *)&AppleMemory[ScanlineOffsetTable[vert] + vidPageOffset]; + nextscanptr = (UInt32 *)&AppleMemory[ScanlineOffsetTable[++vert] + vidPageOffset]; + for (hori = 0; hori < 10; hori++) + shrinkScans[hori] = *scanptr++ | *nextscanptr++; + pfnHires((UInt8 *)&shrinkScans, _pointer, &vidScreenCache[VID_CACHE_OFFSET(vert)]); + } + else + { + pfnHires(&AppleMemory[ScanlineOffsetTable[vert] + vidPageOffset], _pointer, &vidScreenCache[VID_CACHE_OFFSET(vert)]); + } + _pointer += pitch; + } + chary = 0; + textpage = SS_ISSET(vidIOU, SS_PAGE2) ? 0x0800 : 0x0400; + while (vert < 192/*144*/) + { + pfnText(&AppleMemory[ScanlineOffsetTable[vert] + textpage], _pointer, &vidScreenCache[VID_CACHE_OFFSET(vert)]); + _pointer += pitch * 6; + vert += 8; + } +} +void gryUpdateHiresMixed(void) +{ + defUpdateHiresMixed(gryUpdateHiresScanline, gryUpdateTextRow, 40); +} +void clrUpdateHiresMixed(void) +{ + defUpdateHiresMixed(clrUpdateHiresScanline, clrUpdateTextRow, 160); +} +void hrclrUpdateTextRow(UInt8 *, UInt8 *, UInt8 *); +void hrclrUpdateText(void) +{ + Int16 vert; + UInt8 *_pointer = vidImage; + dirtyVideo = false; + for (vert = 0; vert < 192; vert += 8) + { + hrclrUpdateTextRow(&AppleMemory[ScanlineOffsetTable[vert] + vidPageOffset], _pointer, &vidScreenCache[VID_CACHE_OFFSET(vert)]); + _pointer += 320 * 9; + } +} +void hrclrUpdateDblTextRow(UInt8 *, UInt8 *, UInt8 *); +void hrclrUpdateDblText(void) +{ + Int16 vert; + UInt8 *_pointer = vidImage; + dirtyVideo = false; + for (vert = 0; vert < 192; vert += 8) + { + hrclrUpdateDblTextRow(&AuxMemory[ScanlineOffsetTable[vert] + 16384], _pointer, &vidScreenCache[VID_CACHE_OFFSET(vert + 1)]); + hrclrUpdateDblTextRow(&AppleMemory[ScanlineOffsetTable[vert] + vidPageOffset], _pointer + 4, &vidScreenCache[VID_CACHE_OFFSET(vert)]); + _pointer += 320 * 9; + } +} +void hrclrUpdateLoresRow(UInt8 *, UInt8 *, UInt8 *); +void hrclrUpdateLoresMixed(void) +{ + Int16 vert; + UInt8 *_pointer = vidImage; + dirtyVideo = false; + for (vert = 0; vert < 160; vert += 8) + { + hrclrUpdateLoresRow(&AppleMemory[ScanlineOffsetTable[vert] + vidPageOffset], _pointer, &vidScreenCache[VID_CACHE_OFFSET(vert)]); + _pointer += 320 * 9; + } + while (vert < 192) + { + hrclrUpdateTextRow(&AppleMemory[ScanlineOffsetTable[vert] + vidPageOffset], _pointer, &vidScreenCache[VID_CACHE_OFFSET(vert)]); + _pointer += 320 * 9; + vert += 8; + } +} +void hrclrUpdateLores(void) +{ + Int16 vert; + UInt8 *_pointer = vidImage; + dirtyVideo = false; + for (vert = 0; vert < 192; vert += 8) + { + hrclrUpdateLoresRow(&AppleMemory[ScanlineOffsetTable[vert] + vidPageOffset], _pointer, &vidScreenCache[VID_CACHE_OFFSET(vert)]); + _pointer += 320 * 9; + } +} +void hrclrUpdateHiresScanline(UInt8 *, UInt8 *, UInt8 *); +void hrclrUpdateHiresDblScanline(UInt8 *, UInt8 *, UInt8 *); +void hrclrUpdateHiresMixed(void) +{ + Int16 vert, textpage; + UInt8 *_pointer = vidImage; + dirtyVideo = false; + for (vert = 0; vert < 160; vert++) + { + if ((vert & 7) == 0) + { + hrclrUpdateHiresDblScanline(&AppleMemory[ScanlineOffsetTable[vert] + vidPageOffset], _pointer, &vidScreenCache[VID_CACHE_OFFSET(vert)]); + _pointer += 640; + } + else + { + hrclrUpdateHiresScanline(&AppleMemory[ScanlineOffsetTable[vert] + vidPageOffset], _pointer, &vidScreenCache[VID_CACHE_OFFSET(vert)]); + _pointer += 320; + } + } + textpage = SS_ISSET(vidIOU, SS_PAGE2) ? 0x0800 : 0x0400; + while (vert < 192) + { + hrclrUpdateTextRow(&AppleMemory[ScanlineOffsetTable[vert] + textpage], _pointer, &vidScreenCache[VID_CACHE_OFFSET(vert)]); + _pointer += 320 * 9; + vert += 8; + } +} +void hrclrUpdateHires(void) +{ + Int16 vert; + UInt8 *_pointer = vidImage; + dirtyVideo = false; + for (vert = 0; vert < 192; vert++) + { + if ((vert & 7) == 0) + { + hrclrUpdateHiresDblScanline(&AppleMemory[ScanlineOffsetTable[vert] + vidPageOffset], _pointer, &vidScreenCache[VID_CACHE_OFFSET(vert)]); + _pointer += 640; + } + else + { + hrclrUpdateHiresScanline(&AppleMemory[ScanlineOffsetTable[vert] + vidPageOffset], _pointer, &vidScreenCache[VID_CACHE_OFFSET(vert)]); + _pointer += 320; + } + } +} diff --git a/utils/dsk2pdb.c b/utils/dsk2pdb.c new file mode 100755 index 0000000..577fe28 --- /dev/null +++ b/utils/dsk2pdb.c @@ -0,0 +1,685 @@ +#include +#include +#include +#ifdef __APPLE_CC__ +#include +#else +#include +#endif +#define TRUE 1 +#define FALSE 0 + +typedef unsigned char BYTE; +typedef unsigned ADDR; + +typedef unsigned char UInt8; +typedef char Int8; +typedef unsigned short UInt16; +typedef short Int16; +typedef unsigned long UInt32; +typedef long Int32; +typedef unsigned long LocalID; + +#ifdef __APPLE_CC__ +#define BE_UINT8(b) ((UInt8)(b)) +#define BE_UINT16(i) ((UInt16)(i)) +#define BE_UINT32(i) ((UInt32)(i)) +#define BE_INT8(b) ((Int8)(b)) +#define BE_INT16(i) ((Int16)(i)) +#define BE_INT32(i) ((Int32)(i)) +#define BE_LOCALID(i) ((Int32)(i)) +#else +#define BE_UINT8(b) ((UInt8)(b)) +#define BE_UINT16(i) ((((UInt16)(i)&0xFF00)>>8)|(((UInt16)(i)&0xFF)<<8)) +#define BE_UINT32(i) (((((UInt32)(i))>>24))|((((UInt32)(i))>>8)&0x0000FF00)|((((UInt32)(i))<<8)&0x00FF0000)|(((UInt32)(i))<<24)) +#define BE_INT8(b) ((UInt8)(b)) +#define BE_INT16(i) ((((UInt16)(i)&0xFF00)>>8)|(((UInt16)(i)&0xFF)<<8)) +#define BE_INT32(i) (((((UInt32)(i))>>24))|((((UInt32)(i))>>8)&0x0000FF00)|((((UInt32)(i))<<8)&0x00FF0000)|(((UInt32)(i))<<24)) +#define BE_LOCALID(i) (((((UInt32)(i))>>24))|((((UInt32)(i))>>8)&0x0000FF00)|((((UInt32)(i))<<8)&0x00FF0000)|(((UInt32)(i))<<24)) +#endif + +#ifdef _WIN32 +#define RDSK 'RDSK' +#define DDSK 'DDSK' +#define Apl2 'Apl2' +#else +#define RDSK BE_UINT32('RDSK') +#define DDSK BE_UINT32('DDSK') +#define Apl2 BE_UINT32('Apl2') +#endif +typedef struct { + LocalID localChunkID; + UInt8 attributes; + UInt8 uniqueID[3]; +} RecordEntryType; +typedef struct { + LocalID nextRecordListID; + UInt16 numRecords; + UInt16 firstEntry; +} RecordListType; +typedef struct { + UInt8 name[32]; + UInt16 attributes; + UInt16 version; + UInt32 creationDate; + UInt32 modificationDate; + UInt32 lastBackupDate; + UInt32 modificationNumber; + LocalID appInfoID; + LocalID sortInfoID; + UInt32 type; + UInt32 creator; + UInt32 uniqueIDSeed; + RecordListType recordList; +} DatabaseHdrType; + + + +#define SIGN_EXTEND(x) ((int)((char)x)) +/* + * GCR encoding/decoding utility + * + */ + +/* + * raw track + * this is obtained by + * 14.31818MHz / 14 / 32 / 8 + * + */ +#define RAW_TRACK_BYTES 6192/*6320*/ +#define DOS_TRACK_BYTES 4096 +#define RAW_TRACK_BITS (RAW_TRACK_BYTES*8) + +static FILE *diskimage; +static int write_mode; +static int write_protect; +static BYTE nibble[RAW_TRACK_BYTES]; +static BYTE dos_track[4096]; +static int position; +static int current_slot; /* Current slot we have open */ +static int current_drive; /* Current drive we have open */ + /* i.e to which diskimage points */ +static int motor_on; +static int physical_track_no; +static int stepper_status; +static int track_buffer_valid=0; +static int track_buffer_dirty=0; +static int track_buffer_track=0; + +static BYTE data_latch; +static BYTE address_latch; +static UInt32 LastAppleClock, AppleClock; + +static BYTE boot_ROM[256]; + +char *DiskROM= "DISK.ROM"; + +static BYTE GCR_encoding_table[64] = { + 0x96, 0x97, 0x9A, 0x9B, 0x9D, 0x9E, 0x9F, 0xA6, + 0xA7, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB2, 0xB3, + 0xB4, 0xB5, 0xB6, 0xB7, 0xB9, 0xBA, 0xBB, 0xBC, + 0xBD, 0xBE, 0xBF, 0xCB, 0xCD, 0xCE, 0xCF, 0xD3, + 0xD6, 0xD7, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, + 0xDF, 0xE5, 0xE6, 0xE7, 0xE9, 0xEA, 0xEB, 0xEC, + 0xED, 0xEE, 0xEF, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, + 0xF7, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF }; + +static BYTE GCR_decoding_table[256]; +static int Swap_Bit[4] = { 0, 2, 1, 3 }; /* swap lower 2 bits */ +static BYTE GCR_buffer[256]; +static BYTE GCR_buffer2[86]; + +static int Position=0; +static BYTE *Track_Nibble; + +/* physical sector no. to DOS 3.3 logical sector no. table */ +static int Logical_Sector[16] = { + 0x0, 0x7, 0xE, 0x6, 0xD, 0x5, 0xC, 0x4, + 0xB, 0x3, 0xA, 0x2, 0x9, 0x1, 0x8, 0xF }; + +static int Physical_Sector[16]; + +/* static function prototypes */ + +static void init_GCR_table(void); +static BYTE gcr_read_nibble(void); +static void gcr_write_nibble( BYTE ); +static void decode62( BYTE* ); +static void encode62( BYTE* ); +static void FM_encode( BYTE ); +static BYTE FM_decode(void); +static void write_sync( int ); +static int read_address_field( int*, int*, int* ); +static void write_address_field( int, int, int ); +static int read_data_field(void); +static void write_data_field(void); + +#define FM_ENCODE(x) gcrWriteNibble( ((x) >> 1) | 0xAA );\ + gcrWriteNibble( (x) | 0xAA ) + +static void init_GCR_table(void) +{ + static int initialized = 0; + int i; + + if ( !initialized ) { + for( i = 0; i < 64; i++ ) + GCR_decoding_table[GCR_encoding_table[i]] = i; + for( i = 0; i < 16; i++ ) + Physical_Sector[Logical_Sector[i]] = i; + initialized = 1; + } +} + +static BYTE gcr_read_nibble(void) +{ + BYTE data; + + data = Track_Nibble[Position++]; + if ( Position >= RAW_TRACK_BYTES ) + Position = 0; + return data; +} + +static void gcr_write_nibble( BYTE data ) +{ + Track_Nibble[Position++] = data; + if ( Position >= RAW_TRACK_BYTES ) + Position = 0; +} + +static void decode62( BYTE *page ) +{ + int i, j; + + /* get 6 bits from GCR_buffer & 2 from GCR_buffer2 */ + for( i = 0, j = 86; i < 256; i++ ) { + if ( --j < 0 ) j = 85; + page[i] = (GCR_buffer[i] << 2) | Swap_Bit[GCR_buffer2[j] & 0x03]; + GCR_buffer2[j] >>= 2; + } +} + +static void encode62( BYTE *page ) +{ + int i, j; + + /* 86 * 3 = 258, so the first two byte are encoded twice */ + GCR_buffer2[0] = Swap_Bit[page[1]&0x03]; + GCR_buffer2[1] = Swap_Bit[page[0]&0x03]; + + /* save higher 6 bits in GCR_buffer and lower 2 bits in GCR_buffer2 */ + for( i = 255, j = 2; i >= 0; i--, j = j == 85? 0: j + 1 ) { + GCR_buffer2[j] = (GCR_buffer2[j] << 2) | Swap_Bit[page[i]&0x03]; + GCR_buffer[i] = page[i] >> 2; + } + + /* clear off higher 2 bits of GCR_buffer2 set in the last call */ + for( i = 0; i < 86; i++ ) + GCR_buffer2[i] &= 0x3f; +} + +/* + * write an FM encoded value, used in writing address fields + */ +static void FM_encode( BYTE data ) +{ + gcr_write_nibble( (data >> 1) | 0xAA ); + gcr_write_nibble( data | 0xAA ); +} + +/* + * return an FM encoded value, used in reading address fields + */ +static BYTE FM_decode(void) +{ + int tmp; + + /* C does not specify order of operand evaluation, don't + * merge the following two expression into one + */ + tmp = (gcr_read_nibble() << 1) | 0x01; + return gcr_read_nibble() & tmp; +} + +static void write_sync( int length ) +{ + while( length-- ) + gcr_write_nibble( 0xFF ); +} + +/* + * read_address_field: try to read a address field in a track + * returns 1 if succeed, 0 otherwise + */ +static int read_address_field( int *volume, int *track, int *sector ) +{ + int max_try; + BYTE nibble; + + max_try = 100; + while( --max_try ) { + nibble = gcr_read_nibble(); + check_D5: + if ( nibble != 0xD5 ) + continue; + nibble = gcr_read_nibble(); + if ( nibble != 0xAA ) + goto check_D5; + nibble = gcr_read_nibble(); + if ( nibble != 0x96 ) + goto check_D5; + *volume = FM_decode(); + *track = FM_decode(); + *sector = FM_decode(); + return ( *volume ^ *track ^ *sector ) == FM_decode() && + gcr_read_nibble() == 0xDE; + } + return 0; +} + +static void write_address_field( int volume, int track, int sector ) +{ + /* + * write address mark + */ + gcr_write_nibble( 0xD5 ); + gcr_write_nibble( 0xAA ); + gcr_write_nibble( 0x96 ); + + /* + * write Volume, Track, Sector & Check-sum + */ + FM_encode( volume ); + FM_encode( track ); + FM_encode( sector ); + FM_encode( volume ^ track ^ sector ); + + /* + * write epilogue + */ + gcr_write_nibble( 0xDE ); + gcr_write_nibble( 0xAA ); + gcr_write_nibble( 0xEB ); +} + +/* + * read_data_field: read_data_field into GCR_buffers, return 0 if fail + */ +static int read_data_field(void) +{ + int i, max_try; + BYTE nibble, checksum; + + /* + * read data mark + */ + max_try = 32; + while( --max_try ) { + nibble = gcr_read_nibble(); + check_D5: + if ( nibble != 0xD5 ) + continue; + nibble = gcr_read_nibble(); + if ( nibble != 0xAA ) + goto check_D5; + nibble = gcr_read_nibble(); + if ( nibble == 0xAD ) + break; + } + if ( !max_try ) /* fails to get address mark */ + return 0; + + for( i = 0x55, checksum = 0; i >= 0; i-- ) { + checksum ^= GCR_decoding_table[gcr_read_nibble()]; + GCR_buffer2[i] = checksum; + } + + for( i = 0; i < 256; i++ ) { + checksum ^= GCR_decoding_table[gcr_read_nibble()]; + GCR_buffer[i] = checksum; + } + + /* verify sector checksum */ + if ( checksum ^ GCR_decoding_table[gcr_read_nibble()] ) + return 0; + + /* check epilogue */ + return gcr_read_nibble() == 0xDE && gcr_read_nibble() == 0xAA; +} + +static void write_data_field(void) +{ + int i; + BYTE last, checksum; + + /* write prologue */ + gcr_write_nibble( 0xD5 ); + gcr_write_nibble( 0xAA ); + gcr_write_nibble( 0xAD ); + + /* write GCR encode data */ + for( i = 0x55, last = 0; i >= 0; i-- ) { + checksum = last^ GCR_buffer2[i]; + gcr_write_nibble( GCR_encoding_table[checksum] ); + last = GCR_buffer2[i]; + } + for( i = 0; i < 256; i++ ) { + checksum = last ^ GCR_buffer[i]; + gcr_write_nibble( GCR_encoding_table[checksum] ); + last = GCR_buffer[i]; + } + + /* write checksum and epilogue */ + gcr_write_nibble( GCR_encoding_table[last] ); + gcr_write_nibble( 0xDE ); + gcr_write_nibble( 0xAA ); + gcr_write_nibble( 0xEB ); +} + +void SectorsToNibbles( BYTE *sectors, BYTE *nibbles, int volume, int track ) +{ + int i; + + init_GCR_table(); + Track_Nibble = nibbles; + Position = 0; + + /*write_sync( 128 );*/ + for( i = 0; i < 16; i ++ ) { + encode62( sectors + Logical_Sector[i] * 0x100 ); + write_sync( 16 ); + write_address_field( volume, track, i ); + write_sync( 8 ); + write_data_field(); + } +} + +int NibblesToSectors( BYTE *nibbles, BYTE *sectors, int volume, int track ) +{ + int i, scanned[16], max_try, sectors_read; + int vv, tt, ss; /* volume, track no. and sector no. */ + FILE *fp; + + init_GCR_table(); + Track_Nibble = nibbles; + Position = 0; + + for( i = 0; i < 16; i++ ) + scanned[i] = 0; + sectors_read = 0; + + max_try = 200; + while( --max_try ) { + if ( !read_address_field( &vv, &tt, &ss ) ) + continue; + + if ( (volume && vv != volume ) || tt != track || ss < 0 || ss > 15 ){ + printf("phy sector %d address field invalid\n", ss ); + continue; /* invalid values for vv, tt and ss, try again */ + } + + ss = Logical_Sector[ss]; + if ( scanned[ss] ) /* sector has been read */ + continue; + + if ( read_data_field() ) { + decode62( sectors + ss * 0x100 ); + scanned[ss] = 1; /* this sector's ok */ + sectors_read++; + } + else { + printf("fail reading data field of logical sector %d\n", ss ); + } + } + + /* if has failed to read any one sector, report error */ + if ( sectors_read == 16 ) + return 1; + else { + printf( "sectos_read = %d\n",sectors_read); + for( i = 0; i < 16; i++ ) + if ( !scanned[i] ) + printf( "sector %d(%d) corrupted\n", i, Physical_Sector[i] ); + if((fp = fopen( ".track", "w"))!=NULL) { + fwrite( nibbles, 1, RAW_TRACK_BYTES, fp ); + fclose(fp); + } + return 0; + } +} + +void load_track_buffer(void) +{ + int logical_track; + + if (!diskimage) + return; + + if ( physical_track_no & 0x3 ) { + fprintf( stderr, "Cannot read half track %g!\n", + physical_track_no * 0.25 ); + } + + logical_track = (physical_track_no+1)>>2; + fseek( diskimage, logical_track * DOS_TRACK_BYTES, 0L ); + fread( dos_track, 1, DOS_TRACK_BYTES, diskimage ); + SectorsToNibbles( dos_track, nibble, 254, logical_track ); + track_buffer_track = physical_track_no; +#ifdef DEBUG + printf( "load track %g\n", track_buffer_track*.25 ); +#endif + track_buffer_dirty = 0; + track_buffer_valid = 1; + +} +BYTE read_nibble(void) +{ + BYTE data; + static flag; + + if ( !track_buffer_valid ) { + load_track_buffer(); + } + + flag = !flag; + if ( flag ) + return 0; + + data = nibble[position++]; + if ( position >= RAW_TRACK_BYTES ) + position = 0; + LastAppleClock = AppleClock; + return data; + + +} + +/* wkt -- still somehow need to stop diskRead from + * reading when we don't have a disk to read + */ +int mount_disk( char *filename) +{ + if ( diskimage ) unmount_disk(); + write_protect = 0; + diskimage = fopen( filename, "rb+" ); + if ( !diskimage ) { + write_protect = 1; + diskimage = fopen( filename, "rb" ); + } + if (!diskimage) { + fprintf( stderr, "Fail to mount disk %s\n", filename ); + return -1; + } + else { +#ifdef DEBUG + fprintf( stderr, "Mount disk %s\n", filename ); + fprintf( stderr, "write protected = %d\n", write_protect ); +#endif + current_slot=6; current_drive=0; + load_track_buffer(); + } + return 0; +} + +int unmount_disk() +{ + if ( diskimage ) { + fclose( diskimage ); + diskimage = NULL; + } + return 0; +} +int main(int argc, char **argv) +{ + FILE *pdb; + int tracks, sectors, file_size, header_size, track_size, i, j, cvt2raw, argfilename; + char pdbfile[64], *p; + + DatabaseHdrType pdb_header; + RecordEntryType pdb_record_entries[40]; + int now; + + /* + * Strip leading pathname from executable name. + */ + for (p = argv[0]; *p; p++) + { + if (*p == '/' || *p == '\\') + argv[0] = p + 1; + } + if (!strcmp(argv[0], "dsk2pdb") || !strcmp(argv[0], "dsk2pdb.exe") || !strcmp(argv[0], "DSK2PDB.EXE")) + { + if (argc >= 2) + { + argfilename = 1; + cvt2raw = 0; + if (argv[1][0] == '-') + { + argfilename = 2; + if (argv[1][1] == 'r') + cvt2raw = 1; + } + if (mount_disk(argv[argfilename])) + { + fprintf(stderr, "Unable to mount disk file %s.\n", argv[1]); + exit(1); + } + tracks = 35; + sectors = 16; + fseek(diskimage, 0, SEEK_END); + file_size = ftell(diskimage); + if (argc > argfilename + 1) + { + strcpy(pdbfile, argv[argfilename + 1]); + } + else + { + /* + * Strip leading pathname from DSK name. + */ + for (p = argv[argfilename]; *p; p++) + { + if (*p == '/' || *p == '\\') + argv[argfilename] = p + 1; + } + strcpy(pdbfile, argv[argfilename]); + strcat(pdbfile, ".pdb"); + } + if (!(pdb = fopen(pdbfile, "wb"))) + { + fprintf(stderr, "Unable to create PDB file %s.\n", argv[2]); + exit(1); + } + header_size = 78/*sizeof(DatabaseHdrType)*/ + 8/*sizeof(RecordEntryType)*/ * tracks + 2; + track_size = cvt2raw ? RAW_TRACK_BYTES : (file_size / tracks); + now = time(NULL); + memset(&pdb_header, 0, sizeof(DatabaseHdrType)); + memset(&pdb_record_entries, 0, sizeof(RecordEntryType) * tracks); + if (strlen(argv[argfilename]) >= 31) + argv[argfilename][31] = '\0'; + strcpy(pdb_header.name, argv[argfilename]); + pdb_header.modificationDate = BE_UINT32(now); + pdb_header.creationDate = BE_UINT32(now); + pdb_header.type = (track_size == DOS_TRACK_BYTES) ? DDSK : RDSK; + pdb_header.creator = Apl2; + pdb_header.recordList.numRecords = BE_UINT16(tracks); + for (i = 0; i < tracks; i++) + { + j = header_size + i * track_size; + pdb_record_entries[i].localChunkID = BE_LOCALID(j); + pdb_record_entries[i].attributes = 0x40; + pdb_record_entries[i].uniqueID[0] = i; + } + fwrite(&pdb_header, 78/*sizeof(DatabaseHdrType)*/, 1, pdb); + fwrite(&pdb_record_entries, 8/*sizeof(RecordEntryType)*/, tracks, pdb); + i = 0; + fwrite(&i, 2, 1, pdb); /* Filler */ + if (cvt2raw) + { + for (physical_track_no = 0; physical_track_no < tracks * 4; physical_track_no += 4) + { + load_track_buffer(); + fwrite(nibble, RAW_TRACK_BYTES, 1, pdb); + } + } + else + { + unsigned char *all_tracks = malloc(track_size * tracks); + fseek(diskimage, 0L, 0L); + fread(all_tracks, track_size, tracks, diskimage); + fwrite(all_tracks, track_size, tracks, pdb); + free(all_tracks); + } + unmount_disk(); + fclose(pdb); + } + else + //fprintf(stderr, "Usage: %s [sectors/track (16)] [total tracks (35)]\n", argv[0]); + fprintf(stderr, "Usage: %s [PDB file]\n", argv[0]); + } + else if (!strcmp(argv[0], "pdb2dsk") || !strcmp(argv[0], "pdb2dsk.exe") || !strcmp(argv[0], "PDB2DSK.EXE")) + { + if (argc >= 2) + { + if (!(pdb = fopen(argv[1], "rb"))) + { + fprintf(stderr, "Unable to open PDB file %s.\n", argv[1]); + exit(1); + } + if (argc < 3) + { + fread(&pdb_header, 78/*sizeof(DatabaseHdrType)*/, 1, pdb); + pdb_header.name[31] = '\0'; + if (!(diskimage = fopen(pdb_header.name, "wb"))) + { + fprintf(stderr, "Unable to open DSK file %s.\n", argv[2]); + exit(1); + } + } + else + { + if (!(diskimage = fopen(argv[2], "wb"))) + { + fprintf(stderr, "Unable to open DSK file %s.\n", argv[2]); + exit(1); + } + } + fseek(pdb, 78+8*35+2, 0L); + while (fread(&i, 1, 1, pdb) > 0) + { + fwrite(&i, 1, 1, diskimage); + } + fclose(pdb); + fclose(diskimage); + } + else + //fprintf(stderr, "Usage: %s [sectors/track (16)] [total tracks (35)]\n", argv[0]); + fprintf(stderr, "Usage: %s [DSK file]\n", argv[0]); + } + else + fprintf(stderr, "Unknown launch name: %s\n", argv[0]); + return (0); +} + diff --git a/utils/rom2pdb.c b/utils/rom2pdb.c new file mode 100755 index 0000000..4c75268 --- /dev/null +++ b/utils/rom2pdb.c @@ -0,0 +1,140 @@ +#include +#include +#include +#ifdef __APPLE_CC__ +#include +#else +#include +#endif +#define TRUE 1 +#define FALSE 0 + +typedef unsigned char BYTE; +typedef unsigned ADDR; + +typedef unsigned char UInt8; +typedef char Int8; +typedef unsigned short UInt16; +typedef short Int16; +typedef unsigned long UInt32; +typedef long Int32; +typedef unsigned long LocalID; + +#ifdef __APPLE_CC__ +#define BE_UINT8(b) ((UInt8)(b)) +#define BE_UINT16(i) ((UInt16)(i)) +#define BE_UINT32(i) ((UInt32)(i)) +#define BE_INT8(b) ((Int8)(b)) +#define BE_INT16(i) ((Int16)(i)) +#define BE_INT32(i) ((Int32)(i)) +#define BE_LOCALID(i) ((Int32)(i)) +#else +#define BE_UINT8(b) ((UInt8)(b)) +#define BE_UINT16(i) ((((UInt16)(i)&0xFF00)>>8)|(((UInt16)(i)&0xFF)<<8)) +#define BE_UINT32(i) (((((UInt32)(i))>>24))|((((UInt32)(i))>>8)&0x0000FF00)|((((UInt32)(i))<<8)&0x00FF0000)|(((UInt32)(i))<<24)) +#define BE_INT8(b) ((UInt8)(b)) +#define BE_INT16(i) ((((UInt16)(i)&0xFF00)>>8)|(((UInt16)(i)&0xFF)<<8)) +#define BE_INT32(i) (((((UInt32)(i))>>24))|((((UInt32)(i))>>8)&0x0000FF00)|((((UInt32)(i))<<8)&0x00FF0000)|(((UInt32)(i))<<24)) +#define BE_LOCALID(i) (((((UInt32)(i))>>24))|((((UInt32)(i))>>8)&0x0000FF00)|((((UInt32)(i))<<8)&0x00FF0000)|(((UInt32)(i))<<24)) +#endif + +#ifdef _WIN32 +#define Apl2 'Apl2' +#else +#define Apl2 BE_UINT32('Apl2') +#endif +typedef struct { + LocalID localChunkID; + UInt8 attributes; + UInt8 uniqueID[3]; +} RecordEntryType; +typedef struct { + LocalID nextRecordListID; + UInt16 numRecords; + UInt16 firstEntry; +} RecordListType; +typedef struct { + UInt8 name[32]; + UInt16 attributes; + UInt16 version; + UInt32 creationDate; + UInt32 modificationDate; + UInt32 lastBackupDate; + UInt32 modificationNumber; + LocalID appInfoID; + LocalID sortInfoID; + UInt32 type; + UInt32 creator; + UInt32 uniqueIDSeed; + RecordListType recordList; +} DatabaseHdrType; +int main(int argc, char **argv) +{ + FILE *romimage, *pdb; + int rom_size, header_size, i, j; + char pdbfile[64], *p; + + DatabaseHdrType pdb_header; + RecordEntryType pdb_record_entries[1]; + int now; + + if (argc >= 2) + { + if (!(romimage = fopen(argv[1], "rb"))) + { + fprintf(stderr, "Unable to read ROM file %s.\n", argv[1]); + exit(1); + } + /* + * Strip leading pathname from ROM name. + */ + for (p = argv[1]; *p; p++) + { + if (*p == '/' || *p == '\\') + argv[1] = p + 1; + } + fseek(romimage, 0, SEEK_END); + rom_size = ftell(romimage); + strcpy(pdbfile, argv[1]); + strcat(pdbfile, ".pdb"); + if (!(pdb = fopen(pdbfile, "wb"))) + { + fprintf(stderr, "Unable to create PDB file %s.\n", pdbfile); + exit(1); + } + header_size = 78/*sizeof(DatabaseHdrType)*/ + 8/*sizeof(RecordEntryType)*/ + 2; + now = time(NULL); + memset(&pdb_header, 0, sizeof(DatabaseHdrType)); + memset(&pdb_record_entries, 0, sizeof(RecordEntryType)); + if (strlen(argv[1]) >= 31) + argv[1][31] = '\0'; + strcpy(pdb_header.name, argv[1]); + pdb_header.modificationDate = BE_UINT32(now); + pdb_header.creationDate = BE_UINT32(now); + pdb_header.type = Apl2; + pdb_header.creator = Apl2; + pdb_header.recordList.numRecords = BE_UINT16(1); + j = header_size; + pdb_record_entries[0].localChunkID = BE_LOCALID(j); + pdb_record_entries[0].attributes = 0x40; + pdb_record_entries[0].uniqueID[0] = 0; + fwrite(&pdb_header, 78/*sizeof(DatabaseHdrType)*/, 1, pdb); + fwrite(&pdb_record_entries, 8/*sizeof(RecordEntryType)*/, 1, pdb); + i = 0; + fwrite(&i, 2, 1, pdb); /* Filler */ + { + unsigned char *rom = malloc(rom_size); + fseek(romimage, 0L, 0L); + fread(rom, rom_size, 1, romimage); + fwrite(rom, rom_size, 1, pdb); + free(rom); + } + fclose(romimage); + fclose(pdb); + } + else + //fprintf(stderr, "Usage: %s [sectors/track (16)] [total tracks (35)]\n", argv[0]); + fprintf(stderr, "Usage: %s \n", argv[0]); + return (0); +} +