home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 2: PC / frozenfish_august_1995.bin / bbs / d01xx / d0165.lha / CPM / Source / cz.a < prev    next >
Text File  |  1988-11-22  |  45KB  |  1,970 lines

  1. ;    Z80 - CP/M emulator for Amiga
  2. ;    Main program
  3.  
  4.         section cz,code
  5.  
  6. main:        bra    main2
  7.  
  8. czver:        dc.b    'Cz    Ver: 00054   Date: 25-Sep-88 21:04:06 ',0
  9.  
  10. ;    This source code is released into the public domain for
  11. ;    non-profit use only.
  12. ;    Copyright (C) 1988, Ulf Nordquist. All Rights Reserved !
  13. ;    Ulf Nordquist
  14. ;    Brunnehagen 36
  15. ;    417 47 Gothenburg
  16. ;    Sweden
  17.  
  18. ;    About message
  19. ;                 1           2     3       4         5
  20. ;             12345678901234567890123456789012345678901234567890
  21. abouttext:  dc.b    '----------Z80, ADM3A and CP/M emulator-----------',0 ;1
  22.         dc.b    ' ',0                                                 ;2
  23.         dc.b    'This software is released into the public domain',0  ;3
  24.         dc.b    'for non-profit use only.',0                          ;4
  25.         dc.b    'Copyright (C) 1988 !            Ulf Nordquist.',0    ;5
  26.         dc.b    'All Rights Reserved !           Brunnehagen 36',0    ;6
  27.         dc.b    'Bug reports and comments        417 47 Gothenburg',0 ;7
  28.         dc.b    'are very welcome.               Sweden',0            ;8
  29.         dc.b    0        ;end mark
  30. ;             12345678901234567890123456789012345678901234567890
  31.  
  32. ;    constants
  33.  
  34. aboutcolumns    equ    50
  35. aboutlines    equ    8
  36.  
  37. ;    History
  38. ;    870728 : windowing code copied from rf
  39. ;         z80 processor window
  40. ;    870729 : bth
  41. ;    870731 : read file into z80 program area
  42. ;         z80 emulator one byte opcodes
  43. ;    871018 : move z80emu to zek
  44. ;    871027 : step gadget struct
  45. ;    871104 : wait for IDCMP in emulator loop
  46. ;    871107 : offset for file load
  47. ;         htb
  48. ;    871108 : set pc to start at offset
  49. ;    871111 : console window
  50. ;    871113 : init cpm
  51. ;    871114 : console window data to ce
  52. ;         error5,6
  53. ;    871115 : error msgs to _stderr
  54. ;         menu for cosole window with project-quit
  55. ;    871120 : requesters
  56. ;         z80opcni
  57. ;         memtz80 z80tmem
  58. ;    871121 : openz80win, closez80win
  59. ;         console menu windows-z80 processor
  60. ;         program start offset is now always $100
  61. ;         command line flag s
  62. ;         run/stop gadget in z80 window
  63. ;    871122 : unimplemented opcode requester shows opcode no
  64. ;         oserr
  65. ;    871206 : remove auto read file at startup & s flg
  66. ;         no auto start of z80 window
  67. ;    871207 : disz80
  68. ;    871211 : minpeh
  69. ;    871216 : osexit
  70. ;    871217 : explanation text in oserr requester
  71. ;    871223 : emuinit
  72. ;    880124 : console menu project -about V0.6
  73. ;    880127 : reset gadget in z80 window
  74. ;    880221 : z80opc2ni
  75. ;    880224 : glflgs bit 4
  76. ;         console menu terminal-esc seq trap
  77. ;    880227 : change main loop to include all memory init
  78. ;    880306 : reset is osexit
  79. ;    880307 : console menu terminal-log to file
  80. ;    880430 : ver 00001
  81. ;    880710 : debug menue count & save count
  82. ;    880711 : move emuinit out of cpm reset loop
  83. ;         remove push & pop macros
  84. ;    880713 : debug menue trace
  85. ;    880716 : change about window
  86. ;         project menue version
  87. ;    880910 : include the essential startup code here
  88. ;    880924 : ireg
  89.  
  90. ;    globals from this module
  91.  
  92.         xdef    _DOSBase
  93.         xdef    _SysBase
  94.         xdef    bth16
  95.         xdef    conwinptr
  96.         xdef    error2
  97.         xdef    error4
  98.         xdef    error5
  99.         xdef    error6
  100.         xdef    genntxt
  101.         xdef    gg_GadgetID
  102.         xdef    gg_NextGadget
  103.         xdef    gg_SpecialInfo
  104.         xdef    gg_TopEdge
  105.         xdef    glflgs
  106.         xdef    ireg
  107.         xdef    im_Class
  108.         xdef    im_IAddress
  109.         xdef    intbase
  110.         xdef    minpeh
  111.         xdef    MP_SIGBIT
  112.         xdef    oserr
  113.         xdef    osexit
  114.         xdef    wd_RPort
  115.         xdef    wd_Size
  116.         xdef    wd_UserPort
  117.         xdef    winbp
  118.         xdef    windp
  119.         xdef    winmnh
  120.         xdef    winmxh
  121.         xdef    winmnw
  122.         xdef    winmxw
  123.         xdef    xalloc
  124.         xdef    z80opc2ni
  125.         xdef    z80opcni
  126.         xdef    z80pgmptr
  127.         xdef    z80pgmsiz
  128.         xdef    z80pc
  129.         xdef    z80sp
  130.         xdef    z80winptr
  131.  
  132. ;    externals from zek
  133.  
  134.         xref    emuinit
  135.         xref    savecnt
  136.         xref    startcnt
  137.         xref    stopcnt
  138.         xref    starttrc
  139.         xref    stoptrc
  140.         xref    zekver
  141.         xref    z80emu
  142.         xref    z80emucont
  143.  
  144. ;    externals from ce
  145.  
  146.         xref    cever
  147.         xref    closelog
  148.         xref    comdata
  149.         xref    conchk
  150.         xref    conmsgpsb
  151.         xref    conout1
  152.         xref    conwin
  153.         xref    dbgconwin
  154.         xref    newline
  155.         xref    openlog
  156.         xref    osclose
  157.         xref    osrun
  158.  
  159. ;    externals from zekcb
  160.  
  161.         xref    zekcbver
  162.  
  163. ;    externals from zekdd
  164.  
  165.         xref    zekddver
  166.  
  167. ;    externals from zeked
  168.  
  169.         xref    zekedver
  170.  
  171. ;    externals from exec.library
  172.  
  173.         xref    _LVOCloseLibrary
  174.         xref    _LVOGetMsg
  175.         xref    _LVOFindTask
  176.         xref    _LVOReplyMsg
  177.         xref    _LVOOpenLibrary
  178.         xref    _LVOWait
  179.  
  180. ;    externals from intuition.library
  181.  
  182.         xref    _LVOAllocRemember
  183.         xref    _LVOAutoRequest
  184.         xref    _LVOClearMenuStrip
  185.         xref    _LVOCloseWindow
  186.         xref    _LVOFreeRemember
  187.         xref    _LVOIntuiTextLength
  188.         xref    _LVOItemAddress
  189.         xref    _LVOModifyIDCMP
  190.         xref    _LVOOffMenu
  191.         xref    _LVOOnMenu
  192.         xref    _LVOOpenWindow
  193.         xref    _LVOPrintIText
  194.         xref    _LVOSetMenuStrip
  195.  
  196. ;    externals from dos.library
  197.  
  198.         xref    _LVOOutput
  199.         xref    _LVOWrite
  200.  
  201. ;    equates
  202. ;    include/exec
  203.  
  204. _AbsExecBase    equ    4
  205.  
  206. ;    include/exec/memory.i
  207.  
  208. MEMF_ANY    equ    0
  209. TRUE        equ    -1
  210.  
  211. ;    include/exec/ports.i
  212.  
  213. MP_SIGBIT    equ    15        ;rel ptr to message port sigbit #
  214.  
  215. ;    include/graphics/rastport.i
  216.  
  217. RP_JAM1     equ    0
  218. RP_JAM2     equ    1
  219.  
  220. ;    include/intuition/intuition.i
  221. ;    various
  222.  
  223. BOOLGADGET    equ    $0001
  224. CHECKED     equ    $0100
  225. CHECKIT     equ    $0001
  226. CHECKWIDTH    equ    19
  227. CLOSEWINDOW    equ    $00000200
  228. GADGETUP    equ    $00000040
  229. GADGHCOMP    equ    $0000
  230. HIGHCOMP    equ    $0040
  231. ITEMENABLED    equ    $0010
  232. ITEMTEXT    equ    $0002
  233. MENUENABLED    equ    $0001
  234. MENUNULL    equ    $ffff
  235. MENUPICK    equ    $00000100
  236. RELVERIFY    equ    $0001
  237. WBENCHSCREEN    equ    $0001
  238. WINDOWCLOSE    equ    $0008
  239. WINDOWDEPTH    equ    $0004
  240. WINDOWDRAG    equ    $0002
  241. WINDOWSIZING    equ    $0001
  242.  
  243. ;    relative pointers into gadget structure
  244.  
  245. gg_NextGadget    equ    0
  246. gg_LeftEdge    equ    4
  247. gg_TopEdge    equ    6
  248. gg_Width    equ    8
  249. gg_Height    equ    10
  250. gg_Flags    equ    12
  251. gg_Activation    equ    14
  252. gg_GadgetType    equ    16
  253. gg_GadgetRender equ    18
  254. gg_SelectRender equ    22
  255. gg_GadgetText    equ    26
  256. gg_MutualExclude equ    30
  257. gg_SpecialInfo    equ    34
  258. gg_GadgetID    equ    38
  259. gg_UserData    equ    40
  260. gg_SIZEOF    equ    44
  261.  
  262. ;    relative pointers into intuimessage structure
  263.  
  264. im_ExecMessage    equ    0
  265. im_Class    equ    20
  266. im_Code     equ    24
  267. im_Qualifier    equ    26
  268. im_IAddress    equ    28
  269. im_MouseX    equ    32
  270. im_MouseY    equ    34
  271. im_Seconds    equ    36
  272. im_Micros    equ    40
  273. im_IDCMPWindow    equ    44
  274. im_SpecialLink    equ    48
  275. im_SIZEOF    equ    52
  276.  
  277. ;    relative pointers into menuitem structure
  278.  
  279. mi_NextItem    equ    0
  280. mi_LeftEdge    equ    4
  281. mi_TopEdge    equ    6
  282. mi_Width    equ    8
  283. mi_Height    equ    10
  284. mi_Flags    equ    12
  285. mi_MutualExclude equ    14
  286. mi_ItemFill    equ    18
  287. mi_SelectFill    equ    22
  288. mi_Command    equ    26
  289. mi_KludgeFill00 equ    27
  290. mi_SubItem    equ    28
  291. mi_NextSelect    equ    32
  292. mi_SIZEOF    equ    34
  293.  
  294. ;    relative pointers into window structure
  295.  
  296. wd_NextWindow    equ    0
  297. wd_LeftEdge    equ    4
  298. wd_TopEdge    equ    6
  299. wd_Width    equ    8
  300. wd_Height    equ    10
  301. wd_MouseY    equ    12
  302. wd_MouseX    equ    14
  303. wd_MinWidth    equ    16
  304. wd_MinHeight    equ    18
  305. wd_MaxWidth    equ    20
  306. wd_MaxHeight    equ    22
  307. wd_Flags    equ    24
  308. wd_MenuStrip    equ    28
  309. wd_Title    equ    32
  310. wd_FirstRequest equ    36
  311. wd_DMRequest    equ    40
  312. wd_ReqCount    equ    44
  313. wd_WScreen    equ    46
  314. wd_RPort    equ    50
  315. wd_BorderLeft    equ    54
  316. wd_BorderTop    equ    55
  317. wd_BorderRight    equ    56
  318. wd_BorderBottom equ    57
  319. wd_BorderRPort    equ    58
  320. wd_FirstGadget    equ    62
  321. wd_Parent    equ    66
  322. wd_Descendant    equ    70
  323. wd_Pointer    equ    74
  324. wd_PtrHeight    equ    78
  325. wd_PtrWidth    equ    79
  326. wd_XOffset    equ    80
  327. wd_YOffset    equ    81
  328. wd_IDCMPFlags    equ    82
  329. wd_UserPort    equ    86
  330. wd_WindowPort    equ    90
  331. wd_MessageKey    equ    94
  332. wd_DetailPen    equ    98
  333. wd_BlockPen    equ    99
  334. wd_CheckMark    equ    100
  335. wd_ScreenTitle    equ    104
  336. wd_GZZMouseX    equ    108
  337. wd_GZZMouseY    equ    110
  338. wd_GZZWidth    equ    112
  339. wd_GZZHeight    equ    114
  340. wd_ExtData    equ    116
  341. wd_UserData    equ    120
  342. wd_WLayer    equ    124
  343. wd_Size     equ    128
  344.  
  345. ;    include/libraries/dosextens.i
  346.  
  347. pr_CLI        equ    172    ;bptr, to ConsoleLineInterpreter
  348.  
  349. ;    ascii control
  350.  
  351. cr        equ    $0d
  352. lf        equ    $0a
  353.  
  354. ;    various
  355.  
  356. buflen        equ    32        ;scratch buffer byte length
  357. chrh        equ    7        ;character height
  358. chrw        equ    8        ;character width
  359. errcode     equ    50        ;exit code at error
  360. libver        equ    33        ;library version
  361. osxfer        equ    $ed01        ;opcode for cpm emulator transfer
  362. runcnt        equ    1000        ;instruction per loop in run mode
  363. z80pgmsiz    equ    $10000        ;size of z80 program area
  364.  
  365. ;    common for all windows
  366.  
  367. winx        equ    0        ;initial x pos of top left corner
  368. winy        equ    0        ;initial y pos of top left corner
  369. winmxw        equ    640        ;max width
  370. winmnw        equ    200        ;min width
  371. winmxh        equ    200        ;max height
  372. winmnh        equ    60        ;min height
  373. windp        equ    0        ;detail pen
  374. winbp        equ    1        ;block pen
  375.  
  376. ;    z80 processor window
  377. ;    size
  378.  
  379. z80winw     equ    260        ;width
  380. z80winh     equ    70        ;height
  381.  
  382. ;    step gadget
  383.  
  384. stepid        equ    10        ;id#
  385. z80stpx     equ    10        ;top x
  386. z80stpy     equ    z80winh-15    ;top y
  387. z80stpw     equ    4*chrw+2    ;width
  388. z80stph     equ    chrh+2        ;height
  389.  
  390. ;    run/stop gadget
  391.  
  392. rsid        equ    11        ;id#
  393. z80rsx        equ    z80stpx+z80stpw+10 ;top x
  394. z80rsy        equ    z80stpy     ;top y
  395. z80rsw        equ    4*chrw+2    ;width
  396. z80rsh        equ    chrh+2        ;height
  397.  
  398. ;    reset gadget
  399.  
  400. resid        equ    12        ;id#
  401. z80resx     equ    z80rsx+z80rsw+10 ;top x
  402. z80resy     equ    z80stpy     ;top y
  403. z80resw     equ    5*chrw+2    ;width
  404. z80resh     equ    chrh+2        ;height
  405.  
  406. ;    about window
  407. ;    size
  408.  
  409. aboutwinw    equ    (aboutcolumns+2)*chrw ;width
  410. aboutwinh    equ    (aboutlines+2)*(chrh+2) ;height
  411.  
  412. ;    version window
  413. ;    size
  414.  
  415. verwinw     equ    aboutwinw    ;width
  416. verwinh     equ    (6+1+2)*(chrh+2) ;(mod+task+marg) height
  417.  
  418. ;    console menu strip
  419.  
  420. projectmenu    equ    0
  421. aboutitem    equ    0
  422. veritem     equ    1
  423. quititem    equ    2
  424.  
  425. windowsmenu    equ    1
  426. z80pitem    equ    0
  427.  
  428. terminalmenu    equ    2
  429. escseqitem    equ    0
  430. logitem     equ    1
  431.  
  432. debugmenu    equ    3
  433. countitem    equ    0
  434. savecitem    equ    1
  435. traceitem    equ    2
  436.  
  437. ;    requesters
  438.  
  439. reqh        equ    62        ;height
  440. reqoffx     equ    6
  441. reqoffy     equ    3
  442. reqwadd     equ    25        ;extra width
  443. abreqh        equ    reqh+(6-2)*chrh ;about requester height
  444.  
  445. ;    the program continues here
  446. ;    5-11,13,14,17,18,20->
  447.  
  448.         ds.w    0            ;alignment
  449.  
  450. main2:        move.l    sp,spsave
  451.         move.l    _AbsExecBase,a6
  452.         move.l    a6,_SysBase
  453.  
  454. ;    check if started from CLI
  455.  
  456.         suba.l    a1,a1
  457.         jsr    _LVOFindTask(a6)
  458.         move.l    d0,a4
  459.         tst.l    pr_CLI(A4)
  460.         beq    errexit         ;if no CLI ptr
  461.  
  462. ;    open DOS
  463.  
  464.         move.l    #doslib,a1        ;ptr name string
  465.         move.l    #libver,d0        ;ver #
  466.         jsr    _LVOOpenLibrary(a6)
  467.         move.l    d0,_DOSBase
  468.         beq    errexit         ;if no DOS
  469.  
  470. ;    open intuition
  471.  
  472.         move.l    #intlib,a1        ;ptr name string
  473.         move.l    #libver,d0        ;ver #
  474.         jsr    _LVOOpenLibrary(a6)
  475.         or.l    d0,d0
  476.         beq    error1            ;if no intuition
  477.         move.l    d0,intbase
  478.  
  479. ;    allocate needed memory
  480.  
  481.         move.l    #z80pgmsiz,d0
  482.         bsr    xalloc            ;z80 memory area
  483.         beq    error3            ;if no place
  484.         move.l    d0,z80pgmptr
  485.         move.l    d0,d7
  486.  
  487. ;    open console window and attach IDCMP and menu
  488.  
  489.         move.l    #conwin,a0        ;normal window ptr
  490.         tst.b    debug
  491.         beq.s    main3            ;if no debug
  492.         move.l    #dbgconwin,a0        ;debug window ptr
  493. main3:        move.l    intbase,a6
  494.         jsr    _LVOOpenWindow(a6)
  495.         or.l    d0,d0
  496.         beq    error2            ;if no window
  497.         move.l    d0,conwinptr        ;window ptr
  498.         move.l    d0,d2
  499.         move.l    d0,a0            ;con win ptr
  500.         move.l    #MENUPICK,d0        ;flgs
  501.         jsr    _LVOModifyIDCMP(a6)
  502.         move.l    d2,a0            ;con win ptr
  503.         move.l    #conmenu,a1
  504.         jsr    _LVOSetMenuStrip(a6)
  505.         jsr    emuinit
  506.  
  507. ;    main restart entry
  508. ;    entry from reset and exit from running program
  509. ;    setup z80 registers
  510.  
  511. main1:        move.l    spsave,sp        ;set sp
  512.         move.w    #0+(z80regend-z80regstart)/2-1,d0
  513.         move.l    #z80regstart,a0
  514. main4:        clr.w    (a0)+
  515.         dbra    d0,main4        ;clr regs
  516.         clr.b    ireg            ;and ireg
  517.  
  518. ;    console command processor
  519.  
  520.         move.w    #osxfer,d0        ;cpm opcode
  521.         jsr    osrun
  522.  
  523. ;    BIG emulator loop
  524.  
  525. main12:     bsr    disz80            ;update z80 display
  526.  
  527. ;    SMALL emulator loop
  528.  
  529. main15:     bsr    minpeh            ;handle IDCMP
  530.  
  531. ;    move from memory to registers
  532.  
  533.         move.l    #runcnt,d7
  534.         btst.b    #0,glflgs
  535.         beq.s    main16            ;if z80 run
  536.         moveq.l #1,d7
  537. main16:     move.l    z80pgmptr,a4
  538.         bsr    memtz80
  539.         jsr    z80emu
  540.  
  541. ;    move from registers to memory
  542.  
  543.         bsr    z80tmem
  544.         btst.b    #0,glflgs
  545.         bne    main12            ;if z80stopped, big loop
  546.         bra    main15            ;quick loop
  547.  
  548. ;    error end cleanup
  549.  
  550. errexit:    move.l    #errcode,d7
  551.         bra.s    exit7
  552.  
  553. ;    normal end cleanup
  554. ;    8->
  555.  
  556. exit:        clr.l    d7            ;no error
  557.  
  558. ;    deallocate all memory
  559.  
  560. exit7:        jsr    osclose
  561.         move.l    intbase,d0
  562.         beq.s    exit6            ;if no intuition
  563.         move.l    d0,a6
  564.         move.l    #remkey,a0
  565.         move.l    #TRUE,d0
  566.         jsr    _LVOFreeRemember(a6)
  567.  
  568. ;    remove menus
  569.  
  570. exit6:        move.l    conwinptr,d0        ;window ptr
  571.         beq.s    exit5            ;if no window
  572.         move.l    d0,a0
  573.         jsr    _LVOClearMenuStrip(a6)
  574.  
  575. ;    close all windows
  576.  
  577. exit5:        move.l    #winstart,a5        ;ptr 1:st win ptr
  578. exit1:        move.l    (a5)+,d0
  579.         beq.s    exit1            ;if no ptr
  580.         cmp.l    #$ffffffff,d0
  581.         move.l    d0,a0
  582.         beq.s    exit2            ;if end of win ptrs
  583.         jsr    _LVOCloseWindow(a6)
  584.         bra.s    exit1
  585.  
  586. ;    close all libraries
  587.  
  588. exit2:        move.l    #libstart,a5        ;ptr 1:st lib ptr
  589. exit3:        move.l    (a5)+,d0
  590.         beq.s    exit3            ;if no ptr
  591.         cmp.l    #$ffffffff,d0
  592.         beq.s    exit4            ;if end of lib ptrs
  593.         move.l    d0,a1
  594.         move.l    _SysBase,a6
  595.         jsr    _LVOCloseLibrary(a6)
  596.         bra.s    exit3
  597. exit4:        move.l    d7,d0            ;errcode
  598.         move.l    spsave,sp        ;defensive programming
  599.         rts
  600.  
  601. ;    osexit
  602. ;    exit from emulation, exit from currently running program
  603.  
  604. osexit:     move.l    #newline,comdata
  605.         jsr    conout1
  606.         bra    main1            ;re-enter main loop
  607.  
  608. ;    oserr
  609. ;    display requester and get answer when error in cpm emulator
  610. ;    entry : regs as during emulation
  611. ;        d6.w=ffee, ff=function number, ee=error number
  612. ;        a5.l=ptr to 2:nd text
  613.  
  614. oserr:        bsr    z80tmem         ;save z80 regs
  615.         move.l    #cereqbtd1,a0
  616.         move.w    #1,d4            ;2 no:s
  617. oserr1:     move.b    2(a0),d5
  618.         move.b    d6,d0            ;err #
  619.         bsr    bth8
  620.         move.b    d5,(a0)                 ;restore
  621.         rol.w    #8,d6            ;move fun #
  622.         move.l    #cereqbtd2,a0
  623.         dbra    d4,oserr1        ;loop
  624.         move.l    #cereqbt1,d6        ;body txt ptr
  625.         move.l    a5,cereqbt2d        ;body txt 2 ptr
  626.         bra.s    z80opcni3
  627.  
  628. ;    z80opc2ni
  629. ;    display requester and get answer when unimplemented two byte opcode
  630. ;    entry : regs as during emulation
  631.  
  632. z80opc2ni:    bsr    z80tmem         ;save z80 regs
  633.         subq.w    #1,z80pc        ;back up one step
  634.         move.b    -2(a4,a0.w),d0          ;opcode 1:st
  635.         rol.w    #8,d0
  636.         move.b    -1(a4,a0.w),d0          ;opcode 2:nd
  637.         move.l    #uoreqbtd,a0        ;str ptr
  638.         bsr    bth16            ;opcode to str
  639.         bra.s    z80opcni2
  640.  
  641. ;    z80opcni
  642. ;    display requester and get answer when unimplemented opcode
  643. ;    entry : regs as during emulation
  644.  
  645. z80opcni:    bsr    z80tmem         ;save z80 regs
  646.         move.b    -1(a4,a0.w),d0          ;opcode
  647.         move.l    #uoreqbtd,a0        ;str ptr
  648.         bsr    bth8            ;opcode to str
  649. z80opcni2:    move.l    #uoreqbt,d6        ;body txt ptr
  650.  
  651. ;    entry from other error requesters
  652.  
  653. z80opcni3:    bclr.b    #1,glflgs        ;flg no z80 open
  654.         tst.l    z80winptr
  655.         bne.s    z80opcni1        ;if z80 win exists
  656.         bsr    openz80win
  657.         bset.b    #1,glflgs        ;flg z80 open
  658. z80opcni1:    move.l    d6,a0            ;body txt ptr
  659.         move.l    a0,-(a7)
  660.         move.l    intbase,a6
  661.         jsr    _LVOIntuiTextLength(a6)
  662.         add.l    #reqoffx*2+reqwadd,d0    ;req width
  663.         move.l    d0,d2
  664.         move.l    (a7)+,a1                ;body txt ptr
  665.         move.l    #uoreqpt,a2
  666.         move.l    #uoreqnt,a3        ;txt ptrs
  667.         move.l    z80winptr,a0
  668.         moveq.l #0,d0
  669.         move.l    d0,d1            ;no IDCMP
  670.         move.l    #reqh,d3        ;req height
  671.         jsr    _LVOAutoRequest(a6)
  672.         subq.w    #1,z80pc        ;back up one step
  673.         bset.b    #0,glflgs        ;flg z80 stop
  674.         bsr    disrs            ;update display
  675.         bra    main12            ;enter big loop
  676.  
  677. ;    error routines
  678. ;    error 1 : generic resident library failure
  679.  
  680. error1:     move.l    #e1msg,a5
  681.         bra.s    errend
  682.  
  683. ;    error 2 : not possible to open window
  684.  
  685. error2:     move.l    #e2msg,a5
  686.         bra.s    errend
  687.  
  688. ;    error 3 : not possible to allocate z80 memory
  689.  
  690. error3:     move.l    #e3msg,a5
  691.         bra.s    errend
  692.  
  693. ;    error 4 : generic memory allocation failure
  694.  
  695. error4:     move.l    #e4msg,a5
  696.         bra.s    errend
  697.  
  698. ;    error 5 : not possible to open console device
  699.  
  700. error5:     move.l    #e5msg,a5
  701.         bra.s    errend
  702.  
  703. ;    error 6 : console DoIO error
  704.  
  705. error6:     move.l    #e6msg,a5
  706.         bra.s    errend
  707.  
  708.         nop                ;for short branch
  709.  
  710. ;    common error exit point
  711.  
  712. errend:     move.l    _DOSBase,a6
  713.         jsr    _LVOOutput(a6)
  714.         move.l    d0,d4            ;output handle
  715.         move.l    generr,d3        ;len
  716.         move.l    #generr+4,d2        ;txt ptr
  717.         move.l    d4,d1            ;handle
  718.         jsr    _LVOWrite(a6)           ;write
  719.         move.l    (a5)+,d3                ;len
  720.         move.l    a5,d2            ;txt ptr
  721.         move.l    d4,d1            ;handle
  722.         jsr    _LVOWrite(a6)           ;write
  723.         bra    exit
  724.  
  725. ;    xalloc
  726. ;    allocate fast or chip memory (in that order) with remember
  727. ;    entry : d0=Byte size
  728. ;    exit :    d0=Pointer to memory block
  729. ;        zflg=no alloc
  730. ;    chg :    d0,d1
  731. ;        a0,a1,a6
  732.  
  733. xalloc:     move.l    #MEMF_ANY,d1
  734.         move.l    #remkey,a0
  735.         move.l    intbase,a6
  736.         jsr    _LVOAllocRemember(a6)   ;get mem ptr
  737.         or.l    d0,d0
  738.         rts
  739.  
  740. ;    z80ntxt z80itxt print normal or inverted text in z80 window
  741. ;    genntxt print normal text in any window
  742. ;    entry : (z80?txt) d0.b=x coord, d1.b=y coord, a5=string ptr + <nul>
  743. ;        (genntxt) same + a0.l=ptr rasport struct
  744. ;    chg : d0,d1,a0,a1,a6
  745.  
  746. z80itxt:
  747. z80ntxt:    move.l    z80rasptr,a0        ;ptr rasport struct
  748. genntxt:    move.l    a5,itptr        ;ascii txt ptr
  749.         and.l    #$000000ff,d0        ;make long
  750.         and.l    #$000000ff,d1        ;make long
  751.         move.l    intbase,a6
  752.         move.l    #intuitext,a1        ;ptr intuitext struct
  753.         jmp    _LVOPrintIText(a6)
  754.  
  755. ;    bth32 bth16 bth8
  756. ;    convert 32, 16 or 8 bit binary value to hexadecimal string
  757. ;    no leading zero supression
  758. ;    entry : d0=value, a0=pointer to string area
  759. ;    exit :    a0=ptr <nul>
  760. ;        (string area)=string + <nul>
  761. ;    chg :    d0,d1,d2,a0
  762.  
  763. bth8:        ror.l    #8,d0            ;move 2 lsd
  764.         moveq    #1,d2            ;2 digits
  765.         bra.s    bth2
  766. bth16:        swap    d0            ;move 4 lsd
  767.         moveq    #3,d2            ;4 digits
  768.         bra.s    bth2
  769. bth32:        moveq    #7,d2            ;8 digits
  770. bth2:        rol.l    #4,d0            ;31-28 -> 3-0
  771.         move.l    d0,d1
  772.         and.b    #$0f,d1         ;mask digits
  773.         add.b    #'0',d1                 ;make ascii if 0-9
  774.         cmp.b    #$39,d1
  775.         ble.s    bth1            ;if 0-9
  776.         add.b    #'A'-'9'-1,d1           ;make ascii A-F
  777. bth1:        move.b    d1,(a0)+
  778.         dbra    d2,bth2         ;loop thru all digits
  779.         clr.b    (a0)                    ;end mark
  780.         rts
  781.  
  782. ;    htb
  783. ;    convert hexadecimal string to binary value
  784. ;    convert until non hex digit found
  785. ;    entry : a0=pointer to string + <nul>
  786. ;    exit :    d0=value, a0=pointer to 1:st byte not used
  787. ;    chg  :    d0,d1,a0
  788.  
  789. htb:        clr.l    d0
  790. htb4:        move.b    (a0),d1                 ;get digit
  791.         cmp.b    #'0',d1
  792.         blt.s    htb2            ;if <0
  793.         cmp.b    #'9',d1
  794.         ble.s    htb3            ;if 0-9
  795.         cmp.b    #'A',d1
  796.         blt.s    htb2            ;if <A
  797.         cmp.b    #'F',d1
  798.         bgt.s    htb2            ;if >F
  799. htb3:        lsl.l    #4,d0            ;move for next
  800.         cmp.b    #'A',d1
  801.         blt.s    htb1            ;if 0-9
  802.         sub.b    #'A'-'9'-1,d1           ;compensate for A-F
  803. htb1:        and.b    #$0f,d1         ;clr ascii part
  804.         or.b    d1,d0            ;merge with result
  805.         addq.l    #1,a0            ;nxt digit
  806.         bra.s    htb4            ;loop
  807.  
  808. ;    exit
  809.  
  810. htb2:        rts
  811.  
  812. ;    memtz80
  813. ;    move z80 registers from memory to 68000 registers
  814. ;    chg : d0,d1,d2,d3,d4,d5,a0,a1
  815.  
  816. memtz80:    move.b    z80afp+1,d0        ;f'
  817.         asl.w    #8,d0            ;move to hi
  818.         move.b    z80afp,d0        ;a'
  819.         swap    d0            ;move to hi
  820.         move.w    z80hlp,d1
  821.         swap    d1            ;move to hi
  822.         move.w    z80dep,d2
  823.         swap    d2            ;move to hi
  824.         move.w    z80bcp,d3
  825.         swap    d3            ;move to hi
  826.         move.w    z80ix,d4
  827.         move.w    z80iy,d5
  828.         move.b    z80af+1,d0        ;f
  829.         asl.w    #8,d0            ;move to hi
  830.         move.b    z80af,d0        ;a
  831.         move.w    z80hl,d1
  832.         move.w    z80de,d2
  833.         move.w    z80bc,d3
  834.         move.w    z80pc,a0
  835.         move.w    z80sp,a1
  836.         rts
  837.  
  838. ;    z80tmem
  839. ;    move z80 registers from 68000 registers to memory
  840. ;    chg : d0,d1,d2,d3
  841.  
  842. z80tmem:    ror.w    #8,d0            ;make af
  843.         move.w    d0,z80af
  844.         swap    d0
  845.         ror.w    #8,d0            ;make af'
  846.         move.w    d0,z80afp
  847.         move.w    d1,z80hl
  848.         swap    d1
  849.         move.w    d1,z80hlp
  850.         move.w    d2,z80de
  851.         swap    d2
  852.         move.w    d2,z80dep
  853.         move.w    d3,z80bc
  854.         swap    d3
  855.         move.w    d3,z80bcp
  856.         move.w    d4,z80ix
  857.         move.w    d5,z80iy
  858.         move.w    a0,z80pc
  859.         move.w    a1,z80sp
  860.         rts
  861.  
  862. ;    openz80win
  863. ;    open z80 window, display fixed text, disable menu item
  864. ;    chg : d0,d1,a0,a1,a5,a6
  865.  
  866. openz80win:    tst.l    z80winptr
  867.         beq.s    ozw4            ;if closed
  868.         rts
  869. ozw4:        move.l    #z80win,a0        ;window ptr
  870.         move.l    intbase,a6
  871.         jsr    _LVOOpenWindow(a6)
  872.         or.l    d0,d0
  873.         beq    error2            ;if no window
  874.         move.l    d0,z80winptr        ;window ptr
  875.         move.l    d0,a0
  876.         move.l    wd_RPort(a0),z80rasptr  ;rast port ptr
  877.  
  878. ;    set up text in z80 window
  879.  
  880.         move.l    #z80text,a5        ;ptr start of text
  881. ozw2:        move.b    (a5)+,d0                ;x coord
  882.         beq.s    ozw1            ;if no more txt
  883.         move.b    (a5)+,d1                ;y coord
  884.         bsr    z80ntxt
  885. ozw3:        move.b    (a5)+,d1
  886.         bne.s    ozw3            ;move to end of txt
  887.         bra.s    ozw2            ;loop thru all txt
  888. ozw1:        bsr    disrs
  889.         move.l    conwinptr,a0
  890.         move.l    #windowsmenu+z80pitem*$20,d0
  891.         jmp    _LVOOffMenu(a6)
  892.  
  893. ;    closez80win
  894. ;    close z80 window, enable menu item
  895. ;    chg : d0,d1,a0,a1,a6
  896.  
  897. closez80win:    move.l    z80winptr,d0
  898.         bne.s    czw1            ;if open
  899.         rts
  900. czw1:        move.l    d0,-(a7)
  901.         move.l    intbase,a6
  902.         clr.l    z80winptr        ;mark as not open
  903.         move.l    conwinptr,a0
  904.         move.l    #windowsmenu+z80pitem*$20,d0
  905.         jsr    _LVOOnMenu(a6)
  906.         move.l    (a7)+,a0                ;z80winptr
  907.         jmp    _LVOCloseWindow(a6)
  908.  
  909. ;    disrs
  910. ;    display run/stop gadget text
  911. ;    chg : d0,d1,a0,a1,a5,a6
  912.  
  913. disrs:        tst.l    z80winptr
  914.         bne.s    disrs2            ;if z80 open
  915.         rts
  916. disrs2:     move.b    #z80rsx+1,d0
  917.         move.b    #z80rsy+1,d1        ;x,y coords
  918.         move.l    #stoptxt,a5
  919.         btst.b    #0,glflgs
  920.         beq.s    disrs1            ;if z80 run
  921.         move.l    #runtxt,a5
  922. disrs1:     bra    z80ntxt
  923.  
  924. ;    disz80
  925. ;    display z80 register values in z80 window
  926. ;    chg : d0,d1,a0,a1
  927.  
  928. disz80:     move.l    z80winptr,d0
  929.         bne.s    disz802         ;if z80 win open
  930.         rts
  931. disz802:    move.l    #z80regstart,a3     ;ptr regs
  932.         move.l    #z80regcrd,a4        ;ptr coords
  933.         move.w    #0+(z80regend-z80regstart)/2-1,d3
  934. disz801:    move.b    (a4)+,d0                ;x coord
  935.         move.b    (a4),d1                 ;y coord
  936.         move.l    #spc4,a5
  937.         bsr    z80itxt         ;erase old reg
  938.         move.w    (a3)+,d0                ;reg value
  939.         move.l    #buffer,a5        ;str buf
  940.         move.l    a5,a0
  941.         bsr    bth16
  942.         move.b    -(a4),d0                ;x coord
  943.         addq.l    #1,a4
  944.         move.b    (a4)+,d1                ;y coord
  945.         bsr    z80itxt         ;show new reg
  946.         dbra    d3,disz801        ;loop thru regs
  947.         rts
  948.  
  949. ;    minpeh
  950. ;    main input event handler
  951. ;    if z80 running
  952. ;      only check for signal from IDCMP
  953. ;    if (z80 NOT running) or (ccp running)
  954. ;      check for signal from IDCMP
  955. ;      wait for signal from IDCMP & console.device
  956. ;    handles :
  957. ;    IDCMP z80 window     : step gadget (only exit subroutine)
  958. ;                   run/stop gadget
  959. ;                   reset gadget
  960. ;    IDCMP console window : project menue  - about
  961. ;                          - version
  962. ;                          - quit
  963. ;                   window menue   - z80 processor
  964. ;                   terminal menue - trap esc seq
  965. ;                          - log to file
  966. ;                   debug menue    - count
  967. ;                          - save count
  968. ;                          - trace
  969. ;    console.device         : character input (only exit subroutine)
  970. ;    chg : d0,d1,d2,d3
  971. ;          a0,a1,a2,a3,a5,a6
  972.  
  973. ;    36->
  974.  
  975. minpeh:
  976. minpeh1:    move.l    _SysBase,a6
  977.         move.l    z80winptr,d0
  978.         beq.s    minpeh2         ;if no z80 win
  979.         move.l    d0,a0
  980.         move.l    wd_UserPort(a0),a2      ;z80 IDCMP ptr
  981.         move.l    a2,a0            ;z80 IDCMP ptr
  982.         jsr    _LVOGetMsg(a6)
  983.         or.l    d0,d0
  984.         bne    minpeh3         ;if msg
  985. minpeh2:    move.l    conwinptr,a0
  986.         move.l    wd_UserPort(a0),a3      ;con IDCMP ptr
  987.         move.l    a3,a0            ;con IDCMP ptr
  988.         jsr    _LVOGetMsg(a6)
  989.         or.l    d0,d0
  990.         bne    minpeh15        ;if msg
  991.         btst.b    #2,glflgs
  992.         bne.s    minpeh4         ;if conwait
  993.         btst.b    #0,glflgs
  994.         bne.s    minpeh4         ;if not z80 running
  995.         rts
  996.  
  997. ;    z80 is not running or ccp running
  998. ;    wait for something to happen
  999.  
  1000. minpeh4:    moveq.l #0,d2            ;no sigbit
  1001.         btst.b    #2,glflgs
  1002.         beq.s    minpeh17        ;if no conwait
  1003.         move.b    conmsgpsb,d1        ;sigbit #
  1004.         moveq.l #1,d2
  1005.         asl.l    d1,d2            ;sigbit mask
  1006. minpeh17:    move.l    d2,d3
  1007.         move.l    z80winptr,d0
  1008.         beq.s    minpeh6         ;if no z80 win
  1009.         move.b    MP_SIGBIT(a2),d1        ;z80 sigbit #
  1010.         moveq.l #1,d0
  1011.         asl.l    d1,d0            ;z80 sigbit mask
  1012.         or.l    d0,d2            ;merge con dev & z80 win mask
  1013. minpeh6:    move.b    MP_SIGBIT(a3),d1        ;con sigbit #
  1014.         moveq.l #1,d0
  1015.         asl.l    d1,d0            ;con sigbit mask
  1016.         or.l    d2,d0            ;total mask
  1017.         jsr    _LVOWait(a6)
  1018.         cmp.l    d0,d3
  1019.         bne    minpeh1         ;if not con.dev - chk msg
  1020.         rts
  1021.  
  1022. ;    message from con window
  1023.  
  1024. minpeh15:    move.l    d0,a1            ;ptr msg
  1025.         move.w    im_Code(a1),d2          ;menu #
  1026.         move.l    im_Class(a1),d3         ;IDCMP class
  1027.         jsr    _LVOReplyMsg(a6)
  1028.         cmp.l    #MENUPICK,d3
  1029.         bne    minpeh1         ;if not menu
  1030.  
  1031. ;    handle console menu
  1032.  
  1033. minpeh12:    move.w    d2,d0
  1034.         cmp.w    #MENUNULL,d0
  1035.         beq    minpeh1         ;no valid menu
  1036.         and.w    #$1f,d0
  1037.         cmp.w    #projectmenu,d0
  1038.         beq    minpeh7         ;if project menu
  1039.         cmp.w    #windowsmenu,d0
  1040.         beq    minpeh8         ;if windows menu
  1041.         cmp.w    #terminalmenu,d0
  1042.         beq    minpeh22        ;if terminal menu
  1043.         cmp.w    #debugmenu,d0
  1044.         beq    minpeh27        ;if debug menu
  1045.         bra    minpeh1
  1046.  
  1047. ;    console menu project
  1048.  
  1049. minpeh7:    move.w    d2,d0            ;menu #
  1050.         lsr.w    #5,d0
  1051.         and.w    #$3f,d0
  1052.         cmp.w    #quititem,d0
  1053.         beq.s    minpeh9         ;if quit item
  1054.         cmp.w    #aboutitem,d0
  1055.         beq.s    minpeh18        ;if about item
  1056.         cmp.w    #veritem,d0
  1057.         beq    minpeh33        ;if version item
  1058.         bra    minpeh1         ;no valid item
  1059.  
  1060. ;    console menu project item quit
  1061.  
  1062. minpeh9:    bra    exit
  1063.  
  1064. ;    console menu project item about
  1065. ;    open window
  1066.  
  1067. minpeh18:    move.l    intbase,a6
  1068.         move.l    conwinptr,a0
  1069.         move.l    #projectmenu+aboutitem*$20,d0
  1070.         jsr    _LVOOffMenu(a6)
  1071.         move.l    #aboutwin,a0        ;window ptr
  1072.         jsr    _LVOOpenWindow(a6)
  1073.         or.l    d0,d0
  1074.         beq    error2            ;if no window
  1075.         move.l    d0,a3            ;win ptr
  1076.         move.l    wd_RPort(a3),a2         ;rast port ptr
  1077.  
  1078. ;    display text
  1079.  
  1080.         move.l    #abouttext,a5        ;ptr 1:st line
  1081.         move.b    #chrh+4,d1        ;1:st y coord
  1082. minpeh20:    move.b    #chrw,d0        ;1:st x coord
  1083.         move.b    d1,d2
  1084.         move.l    a2,a0            ;rast port ptr
  1085.         bsr    genntxt
  1086. minpeh19:    tst.b    (a5)+
  1087.         bne.s    minpeh19        ;move to end of line
  1088.         move.b    d2,d1            ;y coord
  1089.         add.b    #chrh+2,d1        ;new y coord
  1090.         tst.b    (a5)
  1091.         bne.s    minpeh20        ;if more lines
  1092.         move.l    #projectmenu+aboutitem*$20,d2
  1093.  
  1094. ;    wait for close gadget
  1095. ;    entry from version item
  1096.  
  1097. minpeh35:    move.l    wd_UserPort(a3),a2      ;IDCMP ptr
  1098.         move.b    MP_SIGBIT(a2),d1        ;sigbit #
  1099.         moveq.l #1,d0
  1100.         asl.l    d1,d0            ;sigbit mask
  1101.         move.l    _SysBase,a6
  1102.         jsr    _LVOWait(a6)
  1103.  
  1104. ;    close window
  1105.  
  1106.         move.l    a3,a0            ;win ptr
  1107.         move.l    intbase,a6
  1108.         jsr    _LVOCloseWindow(a6)
  1109.         move.l    conwinptr,a0
  1110.         move.l    d2,d0            ;menu#
  1111.         jsr    _LVOOnMenu(a6)
  1112.         bra    minpeh1
  1113.  
  1114. ;    console menu project item version
  1115. ;    open window
  1116.  
  1117. minpeh33:    move.l    intbase,a6
  1118.         move.l    conwinptr,a0
  1119.         move.l    #projectmenu+veritem*$20,d0
  1120.         jsr    _LVOOffMenu(a6)
  1121.         move.l    #verwin,a0        ;window ptr
  1122.         jsr    _LVOOpenWindow(a6)
  1123.         or.l    d0,d0
  1124.         beq    error2            ;if no window
  1125.         move.l    d0,a3            ;win ptr
  1126.         move.l    wd_RPort(a3),a2         ;rast port ptr
  1127.  
  1128. ;    display text
  1129.  
  1130.         move.l    a3,-(a7)
  1131.         clr.l    d0
  1132.         move.l    d0,a1            ;null ptr
  1133.         move.l    _SysBase,a6
  1134.         jsr    _LVOFindTask(a6)
  1135.         move.l    intbase,a6
  1136.         move.l    #taskaddr,a0
  1137.         bsr    bth32            ;task addr in hex
  1138.         move.l    #verptrs,a3        ;ptr 1:st ptr
  1139.         move.b    #chrh+4,d1        ;1:st y coord
  1140. minpeh34:    move.b    #chrw,d0        ;1:st x coord
  1141.         move.l    (a3)+,a5                ;a ver txt ptr
  1142.         move.b    d1,d2
  1143.         move.l    a2,a0            ;rast port ptr
  1144.         bsr    genntxt
  1145.         move.b    d2,d1            ;y coord
  1146.         add.b    #chrh+2,d1        ;new y coord
  1147.         tst.l    (a3)
  1148.         bne.s    minpeh34        ;if more ptrs
  1149.  
  1150. ;    close and exit
  1151.  
  1152.         move.l    #projectmenu+veritem*$20,d2 ;menu #
  1153.         move.l    (a7)+,a3                ;win ptr
  1154.         bra    minpeh35
  1155.  
  1156. ;    console menu terminal
  1157.  
  1158. minpeh22:    move.w    d2,d0            ;menu #
  1159.         lsr.w    #5,d0
  1160.         and.w    #$3f,d0
  1161.         cmp.w    #escseqitem,d0
  1162.         beq.s    minpeh23        ;if esc seq item
  1163.         cmp.w    #logitem,d0
  1164.         beq.s    minpeh25        ;if log to file item
  1165.         bra    minpeh1         ;no valid item
  1166.  
  1167. ;    console menu terminal item trap esc seq
  1168.  
  1169. minpeh23:    move.l    cm31me,d0
  1170.         move.w    cm31f,d1
  1171.         and.l    #~(1<<escseqitem),d0    ;clr MutualExclude
  1172.         and.w    #~CHECKED,d1        ;clr CHECKED
  1173.         bclr.b    #4,glflgs        ;flg no trap
  1174.         bne.s    minpeh24        ;if old was trap
  1175.         or.l    #1<<escseqitem,d0    ;set MutualExclude
  1176.         or.w    #CHECKED,d1        ;set CHECKED
  1177.         bset.b    #4,glflgs        ;flg trap
  1178. minpeh24:    move.w    d0,cm31me        ;update MutualExclude
  1179.         move.w    d1,cm31f        ;update menu flags
  1180.         bra    minpeh11
  1181.  
  1182. ;    console menu terminal item log to file
  1183.  
  1184. minpeh25:    move.l    cm32me,d0
  1185.         move.w    cm32f,d1
  1186.         and.l    #~(1<<logitem),d0       ;clr MutualExclude
  1187.         and.w    #~CHECKED,d1        ;clr CHECKED
  1188.         jsr    closelog
  1189.         bne.s    minpeh26        ;if close success
  1190.         jsr    openlog
  1191.         beq.s    minpeh26        ;if open failure
  1192.         or.l    #1<<logitem,d0        ;set MutualExclude
  1193.         or.w    #CHECKED,d1        ;set CHECKED
  1194. minpeh26:    move.w    d0,cm32me        ;update MutualExclude
  1195.         move.w    d1,cm32f        ;update menu flags
  1196.         bra    minpeh11
  1197.  
  1198. ;    console menu debug
  1199.  
  1200. minpeh27:    move.w    d2,d0            ;menu #
  1201.         lsr.w    #5,d0
  1202.         and.w    #$3f,d0
  1203.         cmp.w    #countitem,d0
  1204.         beq.s    minpeh28        ;if debug count item
  1205.         cmp.w    #savecitem,d0
  1206.         beq.s    minpeh29        ;if debug save count item
  1207.         cmp.w    #traceitem,d0
  1208.         beq.s    minpeh31        ;if debug trace item
  1209.         bra    minpeh1         ;no valid item
  1210.  
  1211. ;    console menu debug count
  1212.  
  1213. minpeh28:    move.l    cm41me,d0
  1214.         move.w    cm41f,d1
  1215.         and.l    #~(1<<countitem),d0     ;clr MutualExclude
  1216.         and.w    #~CHECKED,d1        ;clr CHECKED
  1217.         jsr    stopcnt
  1218.         bne.s    minpeh30        ;if stop success
  1219.         jsr    startcnt
  1220.         bne.s    minpeh30        ;if start failure
  1221.         or.l    #1<<countitem,d0    ;set MutualExclude
  1222.         or.w    #CHECKED,d1        ;set CHECKED
  1223. minpeh30:    move.w    d0,cm41me        ;update MutualExclude
  1224.         move.w    d1,cm41f        ;update menu flags
  1225.         bra.s    minpeh11
  1226.  
  1227. ;    console menu debug save count
  1228.  
  1229. minpeh29:    jsr    savecnt
  1230.         bra.s    minpeh11
  1231.  
  1232. ;    console menu debug trace
  1233.  
  1234. minpeh31:    move.l    cm43me,d0
  1235.         move.w    cm43f,d1
  1236.         and.l    #~(1<<traceitem),d0     ;clr MutualExclude
  1237.         and.w    #~CHECKED,d1        ;clr CHECKED
  1238.         jsr    stoptrc
  1239.         bne.s    minpeh32        ;if stop success
  1240.         jsr    starttrc
  1241.         beq.s    minpeh32        ;if start failure
  1242.         or.l    #1<<traceitem,d0    ;set MutualExclude
  1243.         or.w    #CHECKED,d1        ;set CHECKED
  1244. minpeh32:    move.w    d0,cm43me        ;update MutualExclude
  1245.         move.w    d1,cm43f        ;update menu flags
  1246.         bra.s    minpeh11
  1247.  
  1248. ;    console menu windows
  1249.  
  1250. minpeh8:    move.w    d2,d0            ;menu #
  1251.         lsr.w    #5,d0
  1252.         and.w    #$3f,d0
  1253.         cmp.w    #z80pitem,d0
  1254.         beq.s    minpeh10        ;if z80 proc item
  1255.         bra    minpeh1         ;no valid item
  1256.  
  1257. ;    console menu windows item z80 processor
  1258.  
  1259. minpeh10:    bsr    openz80win
  1260.         btst.b    #0,glflgs
  1261.         beq.s    minpeh11        ;if z80 run
  1262.         bsr    disz80
  1263.         bra.s    minpeh11
  1264.         nop                ;for bxx.s
  1265.  
  1266. ;    common console menu exit
  1267. ;    entry : d2.w=menu #
  1268.  
  1269. minpeh11:    move.l    #conmenu,a0        ;ptr MenuStrip
  1270.         moveq.l #0,d0
  1271.         move.w    d2,d0            ;menu #
  1272.         move.l    intbase,a6
  1273.         jsr    _LVOItemAddress(a6)
  1274.         move.w    mi_NextSelect(a0),d2    ;next menu #
  1275.         bra    minpeh12        ;chk nxt
  1276.  
  1277. ;    message from z80 window
  1278.  
  1279. minpeh3:    move.l    d0,a1            ;ptr msg
  1280.         move.l    im_Class(a1),d3         ;IDCMP class
  1281.         move.l    im_IAddress(a1),a3      ;gadget ptr
  1282.         jsr    _LVOReplyMsg(a6)
  1283.         cmp.l    #CLOSEWINDOW,d3
  1284.         beq    minpeh13        ;if close window
  1285.         cmp.l    #GADGETUP,d3
  1286.         bne    minpeh1         ;if not gadget
  1287.  
  1288. ;    handle z80 gadgets
  1289.  
  1290.         move.w    gg_GadgetID(a3),d0
  1291.         cmp.w    #stepid,d0
  1292.         bne.s    minpeh5         ;if not step gadget
  1293.         rts
  1294. minpeh5:    cmp.w    #resid,d0
  1295.         beq.s    minpeh21        ;if reset gadget
  1296.         cmp.w    #rsid,d0
  1297.         bne    minpeh1         ;if not run/stop gadget
  1298.  
  1299. ;    z80 gadget run/stop, toggle flg
  1300.  
  1301.         bset.b    #0,glflgs
  1302.         beq.s    minpeh16        ;if 0
  1303.         bclr.b    #0,glflgs
  1304. minpeh16:    bsr    disrs            ;update display
  1305.         rts
  1306.  
  1307. ;    reset gadget
  1308.  
  1309. minpeh21:    bra    osexit
  1310.  
  1311. ;    z80 closewindow
  1312.  
  1313. minpeh13:    bsr    closez80win
  1314.         bra    minpeh1
  1315.  
  1316. ;    data area
  1317. ;    initialized data area
  1318. ;    strings
  1319. ;    error messages
  1320.  
  1321. generr:     dc.l    generrend-generr-4
  1322.         dc.b    'CPM : '
  1323. generrend:
  1324. e1msg:        dc.l    e1msgend-e1msg-4
  1325.         dc.b    'Not possible to open resident library'
  1326.         dc.b    lf
  1327. e1msgend:
  1328. e2msg:        dc.l    e2msgend-e2msg-4
  1329.         dc.b    'Not possible to open window'
  1330.         dc.b    lf
  1331. e2msgend:
  1332. e3msg:        dc.l    e3msgend-e3msg-4
  1333.         dc.b    'Not possible to allocate z80 memory'
  1334.         dc.b    lf
  1335. e3msgend:
  1336. e4msg:        dc.l    e4msgend-e4msg-4
  1337.         dc.b    'Memory allocation failure'
  1338.         dc.b    lf
  1339. e4msgend:
  1340. e5msg:        dc.l    e5msgend-e5msg-4
  1341.         dc.b    'Not possible to open console device'
  1342.         dc.b    lf
  1343. e5msgend:
  1344. e6msg:        dc.l    e6msgend-e6msg-4
  1345.         dc.b    'Error while writing to console'
  1346.         dc.b    lf
  1347. e6msgend:
  1348.  
  1349. ;    various
  1350.  
  1351. doslib:     dc.b    'dos.library',0
  1352. intlib:     dc.b    'intuition.library',0
  1353. runtxt:     dc.b    'Run ',0
  1354. spc4:        dc.b    '    ',0
  1355. stoptxt:    dc.b    'Stop',0
  1356. taskver:    dc.b    'Task address : '
  1357. taskaddr:    dc.b    '00000000',0
  1358.  
  1359. ;    z80 window data area
  1360. ;    title
  1361.  
  1362. z80winttl:    dc.b    'CP/M Z80 Processor',0
  1363.  
  1364. ;    fixed text
  1365. ;    x, y coords
  1366. ;    text at this position
  1367. ;    end with x coord = 0
  1368.  
  1369. z80text:    dc.b    2*chrw,2*chrh
  1370.         dc.b    'A F  H L  D E  B C  S P  P C',0
  1371.         dc.b    2*chrw,4*chrh+4
  1372.         dc.b    'A F'' H L'' D E'' B C'' I X  I Y',0
  1373.         dc.b    z80stpx+1,z80stpy+1
  1374.         dc.b    'Step',0
  1375.         dc.b    z80resx+1,z80resy+1
  1376.         dc.b    'Reset',0
  1377.         dc.b    0    ;end
  1378.  
  1379. ;    changed text
  1380. ;    coordinates for register in z80 window
  1381. ;    x, y
  1382.  
  1383. z80regcrd:    dc.b    2*chrw,3*chrh+2     ;af
  1384.         dc.b    (2+5)*chrw,3*chrh+2     ;hl
  1385.         dc.b    (2+2*5)*chrw,3*chrh+2   ;de
  1386.         dc.b    (2+3*5)*chrw,3*chrh+2   ;bc
  1387.         dc.b    (2+4*5)*chrw,3*chrh+2   ;sp
  1388.         dc.b    (2+5*5)*chrw,3*chrh+2   ;pc
  1389.         dc.b    2*chrw,5*chrh+4+2    ;af'
  1390.         dc.b    (2+5)*chrw,5*chrh+4+2   ;hl'
  1391.         dc.b    (2+2*5)*chrw,5*chrh+4+2 ;de'
  1392.         dc.b    (2+3*5)*chrw,5*chrh+4+2 ;bc'
  1393.         dc.b    (2+4*5)*chrw,5*chrh+4+2 ;ix
  1394.         dc.b    (2+5*5)*chrw,5*chrh+4+2 ;iy
  1395.  
  1396. ;    z80 NewWindow struct
  1397.  
  1398. z80win:     dc.w    winx,winy        ;top x,y
  1399.         dc.w    z80winw,z80winh     ;width, height
  1400.         dc.b    windp,winbp        ;detail, block pen
  1401.         dc.l    GADGETUP+CLOSEWINDOW    ;idcmp flags
  1402.         dc.l    WINDOWDRAG+WINDOWDEPTH+WINDOWCLOSE ;window flags
  1403.         dc.l    z80step         ;ptr 1st gadget
  1404.         dc.l    0            ;ptr checkmark
  1405.         dc.l    z80winttl        ;ptr title
  1406.         dc.l    0            ;ptr screen
  1407.         dc.l    0            ;ptr bit map
  1408.         dc.w    0,0            ;min width height
  1409.         dc.w    0,0            ;max width height
  1410.         dc.w    WBENCHSCREEN        ;screen type
  1411.  
  1412. ;    z80 window gadget structs
  1413. ;    step
  1414.  
  1415. z80step:    dc.l    z80rs            ;ptr nxt gadget
  1416.         dc.w    z80stpx,z80stpy     ;top x,y
  1417.         dc.w    z80stpw,z80stph     ;width, height
  1418.         dc.w    GADGHCOMP        ;flags
  1419.         dc.w    RELVERIFY        ;activation
  1420.         dc.w    BOOLGADGET        ;gadget type
  1421.         dc.l    0            ;ptr gadget render
  1422.         dc.l    0            ;ptr select render
  1423.         dc.l    0            ;ptr gadget txt
  1424.         dc.l    0            ;mutual exclude
  1425.         dc.l    0            ;ptr spec info
  1426.         dc.w    stepid            ;id#
  1427.         dc.l    0            ;ptr user data
  1428.  
  1429. ;    run/stop
  1430.  
  1431. z80rs:        dc.l    z80res            ;ptr nxt gadget
  1432.         dc.w    z80rsx,z80rsy        ;top x,y
  1433.         dc.w    z80rsw,z80rsh        ;width, height
  1434.         dc.w    GADGHCOMP        ;flags
  1435.         dc.w    RELVERIFY        ;activation
  1436.         dc.w    BOOLGADGET        ;gadget type
  1437.         dc.l    0            ;ptr gadget render
  1438.         dc.l    0            ;ptr select render
  1439.         dc.l    0            ;ptr gadget txt
  1440.         dc.l    0            ;mutual exclude
  1441.         dc.l    0            ;ptr spec info
  1442.         dc.w    rsid            ;id#
  1443.         dc.l    0            ;ptr user data
  1444.  
  1445. ;    reset
  1446.  
  1447. z80res:     dc.l    0            ;ptr nxt gadget
  1448.         dc.w    z80resx,z80resy     ;top x,y
  1449.         dc.w    z80resw,z80resh     ;width, height
  1450.         dc.w    GADGHCOMP        ;flags
  1451.         dc.w    RELVERIFY        ;activation
  1452.         dc.w    BOOLGADGET        ;gadget type
  1453.         dc.l    0            ;ptr gadget render
  1454.         dc.l    0            ;ptr select render
  1455.         dc.l    0            ;ptr gadget txt
  1456.         dc.l    0            ;mutual exclude
  1457.         dc.l    0            ;ptr spec info
  1458.         dc.w    resid            ;id#
  1459.         dc.l    0            ;ptr user data
  1460.  
  1461. ;    about window data area
  1462. ;    title
  1463.  
  1464. aboutwinttl:    dc.b    'About',0
  1465.  
  1466. ;    about NewWindow struct
  1467.  
  1468. aboutwin:    dc.w    winx,winy        ;top x,y
  1469.         dc.w    aboutwinw,aboutwinh    ;width, height
  1470.         dc.b    windp,winbp        ;detail, block pen
  1471.         dc.l    GADGETUP        ;idcmp flags
  1472.         dc.l    0            ;window flags
  1473.         dc.l    aboutclose        ;ptr 1st gadget
  1474.         dc.l    0            ;ptr checkmark
  1475.         dc.l    aboutwinttl        ;ptr title
  1476.         dc.l    0            ;ptr screen
  1477.         dc.l    0            ;ptr bit map
  1478.         dc.w    0,0            ;min width height
  1479.         dc.w    0,0            ;max width height
  1480.         dc.w    WBENCHSCREEN        ;screen type
  1481.  
  1482. ;    about window gadget structs
  1483. ;    close (gadget covers all of window)
  1484.  
  1485. aboutclose:    dc.l    0            ;ptr nxt gadget
  1486.         dc.w    0,0            ;top x,y
  1487.         dc.w    aboutwinw,aboutwinh    ;width, height
  1488.         dc.w    GADGHCOMP        ;flags
  1489.         dc.w    RELVERIFY        ;activation
  1490.         dc.w    BOOLGADGET        ;gadget type
  1491.         dc.l    0            ;ptr gadget render
  1492.         dc.l    0            ;ptr select render
  1493.         dc.l    0            ;ptr gadget txt
  1494.         dc.l    0            ;mutual exclude
  1495.         dc.l    0            ;ptr spec info
  1496.         dc.w    0            ;id#
  1497.         dc.l    0            ;ptr user data
  1498.  
  1499. ;    version window data area
  1500. ;    title
  1501.  
  1502. verwinttl:    dc.b    'Version',0
  1503.  
  1504. ;    version NewWindow struct
  1505.  
  1506. verwin:     dc.w    winx,winy        ;top x,y
  1507.         dc.w    verwinw,verwinh     ;width, height
  1508.         dc.b    windp,winbp        ;detail, block pen
  1509.         dc.l    GADGETUP        ;idcmp flags
  1510.         dc.l    0            ;window flags
  1511.         dc.l    verclose        ;ptr 1st gadget
  1512.         dc.l    0            ;ptr checkmark
  1513.         dc.l    verwinttl        ;ptr title
  1514.         dc.l    0            ;ptr screen
  1515.         dc.l    0            ;ptr bit map
  1516.         dc.w    0,0            ;min width height
  1517.         dc.w    0,0            ;max width height
  1518.         dc.w    WBENCHSCREEN        ;screen type
  1519.  
  1520. ;    version window gadget structs
  1521. ;    close (gadget covers all of window)
  1522.  
  1523. verclose:    dc.l    0            ;ptr nxt gadget
  1524.         dc.w    0,0            ;top x,y
  1525.         dc.w    verwinw,verwinh     ;width, height
  1526.         dc.w    GADGHCOMP        ;flags
  1527.         dc.w    RELVERIFY        ;activation
  1528.         dc.w    BOOLGADGET        ;gadget type
  1529.         dc.l    0            ;ptr gadget render
  1530.         dc.l    0            ;ptr select render
  1531.         dc.l    0            ;ptr gadget txt
  1532.         dc.l    0            ;mutual exclude
  1533.         dc.l    0            ;ptr spec info
  1534.         dc.w    0            ;id#
  1535.         dc.l    0            ;ptr user data
  1536.  
  1537. ;    generic intuitext
  1538.  
  1539.         ds.w    0            ;align
  1540. intuitext:    dc.b    winbp,windp        ;front, back pen
  1541.         dc.b    RP_JAM2         ;draw mode
  1542.         dc.b    0            ;word align fill
  1543.         dc.w    0,0            ;top x,y
  1544.         dc.l    0            ;ptr font
  1545. itptr:        dc.l    0            ;ptr text, to be set
  1546.         dc.l    0            ;ptr next intui text
  1547.  
  1548. ;    MenuStrip for console window
  1549. ;    first menu - Project
  1550.  
  1551. conmenu:    ds.w    0            ;align
  1552. cm1:        dc.l    cm2            ;ptr next menu
  1553.         dc.w    0            ;left edge
  1554.         dc.w    0            ;top edge
  1555.         dc.w    cm1w            ;width
  1556.         dc.w    0            ;height
  1557.         dc.w    MENUENABLED        ;flags
  1558.         dc.l    cm1n            ;ptr name
  1559.         dc.l    cm11            ;ptr 1:st item
  1560.         dcb.w    4,0            ;RJs Jazz&Beat
  1561. cm1n:        dc.b    'Project ',0            ;menu name
  1562. cm1ne:
  1563.  
  1564. cm1w        equ    chrw*(cm1ne-cm1n-1)+2   ;width
  1565.  
  1566. ;    first menu first item - Project About
  1567.  
  1568. cm11:        dc.l    cm12            ;ptr next item
  1569.         dc.w    0            ;rel left edge
  1570.         dc.w    0            ;top edge
  1571.         dc.w    cm1w            ;width
  1572.         dc.w    chrh+2            ;height
  1573.         dc.w    ITEMTEXT+ITEMENABLED+HIGHCOMP ;flags
  1574.         dc.l    0            ;mutual exclude
  1575.         dc.l    cm11t            ;ptr intui text
  1576.         dc.l    0            ;ptr select fill
  1577.         dc.b    0            ;command
  1578.         dc.b    0            ;word align fill
  1579.         dc.l    0            ;ptr sub item
  1580.         dc.w    0            ;next select
  1581. cm11t:        dc.b    windp,winbp        ;front, back pen
  1582.         dc.b    RP_JAM2         ;draw mode
  1583.         dc.b    0            ;word align fill
  1584.         dc.w    0,0            ;top x,y
  1585.         dc.l    0            ;ptr font
  1586.         dc.l    cm11n            ;ptr text
  1587.         dc.l    0            ;ptr next intui text
  1588. cm11n:        dc.b    'About',0               ;item name
  1589. cm11ne:
  1590.  
  1591. ;    first menu second item - Project Version
  1592.  
  1593. cm12:        dc.l    cm13            ;ptr next item
  1594.         dc.w    0            ;rel left edge
  1595.         dc.w    chrh+2            ;top edge
  1596.         dc.w    cm1w            ;width
  1597.         dc.w    chrh+2            ;height
  1598.         dc.w    ITEMTEXT+ITEMENABLED+HIGHCOMP ;flags
  1599.         dc.l    0            ;mutual exclude
  1600.         dc.l    cm12t            ;ptr intui text
  1601.         dc.l    0            ;ptr select fill
  1602.         dc.b    0            ;command
  1603.         dc.b    0            ;word align fill
  1604.         dc.l    0            ;ptr sub item
  1605.         dc.w    0            ;next select
  1606. cm12t:        dc.b    windp,winbp        ;front, back pen
  1607.         dc.b    RP_JAM2         ;draw mode
  1608.         dc.b    0            ;word align fill
  1609.         dc.w    0,0            ;top x,y
  1610.         dc.l    0            ;ptr font
  1611.         dc.l    cm12n            ;ptr text
  1612.         dc.l    0            ;ptr next intui text
  1613. cm12n:        dc.b    'Version',0             ;item name
  1614. cm12ne:
  1615.  
  1616. ;    first menu third item - Project Quit
  1617.  
  1618. cm13:        dc.l    0            ;ptr next item
  1619.         dc.w    0            ;rel left edge
  1620.         dc.w    2*(chrh+2)              ;top edge
  1621.         dc.w    cm1w            ;width
  1622.         dc.w    chrh+2            ;height
  1623.         dc.w    ITEMTEXT+ITEMENABLED+HIGHCOMP ;flags
  1624.         dc.l    0            ;mutual exclude
  1625.         dc.l    cm13t            ;ptr intui text
  1626.         dc.l    0            ;ptr select fill
  1627.         dc.b    0            ;command
  1628.         dc.b    0            ;word align fill
  1629.         dc.l    0            ;ptr sub item
  1630.         dc.w    0            ;next select
  1631. cm13t:        dc.b    windp,winbp        ;front, back pen
  1632.         dc.b    RP_JAM2         ;draw mode
  1633.         dc.b    0            ;word align fill
  1634.         dc.w    0,0            ;top x,y
  1635.         dc.l    0            ;ptr font
  1636.         dc.l    cm13n            ;ptr text
  1637.         dc.l    0            ;ptr next intui text
  1638. cm13n:        dc.b    'Quit',0                ;item name
  1639. cm13ne:
  1640.  
  1641. ;    second menu - Windows
  1642.  
  1643. cm2:        dc.l    cm3            ;ptr next menu
  1644.         dc.w    cm1w+chrw        ;left edge
  1645.         dc.w    0            ;top edge
  1646.         dc.w    cm2w            ;width
  1647.         dc.w    0            ;height
  1648.         dc.w    MENUENABLED        ;flags
  1649.         dc.l    cm2n            ;ptr name
  1650.         dc.l    cm21            ;ptr 1:st item
  1651.         dcb.w    4,0            ;RJs Jazz&Beat
  1652. cm2n:        dc.b    'Windows ',0            ;menu name
  1653. cm2ne:
  1654.  
  1655. cm2w        equ    chrw*(cm2ne-cm2n-1)+2   ;width
  1656.  
  1657. ;    second menu first item - Windows Z80 Processor
  1658.  
  1659. cm21:        dc.l    0            ;ptr next item
  1660.         dc.w    0            ;rel left edge
  1661.         dc.w    0            ;top edge
  1662.         dc.w    chrw*(cm21ne-cm21n)+2   ;width
  1663.         dc.w    chrh+2            ;height
  1664.         dc.w    ITEMTEXT+ITEMENABLED+HIGHCOMP ;flags
  1665.         dc.l    0            ;mutual exclude
  1666.         dc.l    cm21t            ;ptr intui text
  1667.         dc.l    0            ;ptr select fill
  1668.         dc.b    0            ;command
  1669.         dc.b    0            ;word align fill
  1670.         dc.l    0            ;ptr sub item
  1671.         dc.w    0            ;next select
  1672. cm21t:        dc.b    windp,winbp        ;front, back pen
  1673.         dc.b    RP_JAM2         ;draw mode
  1674.         dc.b    0            ;word align fill
  1675.         dc.w    0,0            ;top x,y
  1676.         dc.l    0            ;ptr font
  1677.         dc.l    cm21n            ;ptr text
  1678.         dc.l    0            ;ptr next intui text
  1679. cm21n:        dc.b    'Z80 processor',0       ;item name
  1680. cm21ne:
  1681.  
  1682. ;    third menu - Terminal
  1683.  
  1684. cm3:        dc.l    cm4            ;ptr next menu
  1685.         dc.w    cm1w+cm2w+2*chrw    ;left edge
  1686.         dc.w    0            ;top edge
  1687.         dc.w    cm3w            ;width
  1688.         dc.w    0            ;height
  1689.         dc.w    MENUENABLED        ;flags
  1690.         dc.l    cm3n            ;ptr name
  1691.         dc.l    cm31            ;ptr 1:st item
  1692.         dcb.w    4,0            ;RJs Jazz&Beat
  1693. cm3n:        dc.b    'Terminal ',0            ;menu name
  1694. cm3ne:
  1695.  
  1696. cm3w        equ    chrw*(cm3ne-cm3n-1)+2   ;width
  1697.  
  1698. ;    third menu first item - Terminal Trap Esc Seq
  1699.  
  1700. cm31:        dc.l    cm32            ;ptr next item
  1701.         dc.w    0            ;rel left edge
  1702.         dc.w    0            ;top edge
  1703.         dc.w    chrw*(cm31ne-cm31n)+2   ;width
  1704.         dc.w    chrh+2            ;height
  1705. cm31f:        dc.w    CHECKIT+ITEMTEXT+ITEMENABLED+HIGHCOMP ;flags
  1706. cm31me:     dc.l    0            ;mutual exclude
  1707.         dc.l    cm31t            ;ptr intui text
  1708.         dc.l    0            ;ptr select fill
  1709.         dc.b    0            ;command
  1710.         dc.b    0            ;word align fill
  1711.         dc.l    0            ;ptr sub item
  1712.         dc.w    0            ;next select
  1713. cm31t:        dc.b    windp,winbp        ;front, back pen
  1714.         dc.b    RP_JAM2         ;draw mode
  1715.         dc.b    0            ;word align fill
  1716.         dc.w    0,0            ;top x,y
  1717.         dc.l    0            ;ptr font
  1718.         dc.l    cm31n            ;ptr text
  1719.         dc.l    0            ;ptr next intui text
  1720. cm31n:        dc.b    '  Trap Esc Seq',0      ;item name
  1721. cm31ne:
  1722.  
  1723. ;    third menu second item - Terminal Log to file
  1724.  
  1725. cm32:        dc.l    0            ;ptr next item
  1726.         dc.w    0            ;rel left edge
  1727.         dc.w    chrh+2            ;top edge
  1728.         dc.w    chrw*(cm31ne-cm31n)+2   ;width
  1729.         dc.w    chrh+2            ;height
  1730. cm32f:        dc.w    CHECKIT+ITEMTEXT+ITEMENABLED+HIGHCOMP ;flags
  1731. cm32me:     dc.l    0            ;mutual exclude
  1732.         dc.l    cm32t            ;ptr intui text
  1733.         dc.l    0            ;ptr select fill
  1734.         dc.b    0            ;command
  1735.         dc.b    0            ;word align fill
  1736.         dc.l    0            ;ptr sub item
  1737.         dc.w    0            ;next select
  1738. cm32t:        dc.b    windp,winbp        ;front, back pen
  1739.         dc.b    RP_JAM2         ;draw mode
  1740.         dc.b    0            ;word align fill
  1741.         dc.w    0,0            ;top x,y
  1742.         dc.l    0            ;ptr font
  1743.         dc.l    cm32n            ;ptr text
  1744.         dc.l    0            ;ptr next intui text
  1745. cm32n:        dc.b    '  Log to file',0      ;item name
  1746. cm32ne:
  1747.  
  1748. ;    fourth menu - Debug
  1749.  
  1750. cm4:        dc.l    0            ;ptr next menu
  1751.         dc.w    cm1w+cm2w+cm3w+2*chrw    ;left edge
  1752.         dc.w    0            ;top edge
  1753.         dc.w    cm4w            ;width
  1754.         dc.w    0            ;height
  1755.         dc.w    MENUENABLED        ;flags
  1756.         dc.l    cm4n            ;ptr name
  1757.         dc.l    cm41            ;ptr 1:st item
  1758.         dcb.w    4,0            ;RJs Jazz&Beat
  1759. cm4n:        dc.b    'Debug ',0            ;menu name
  1760. cm4ne:
  1761.  
  1762. cm4w        equ    chrw*(cm4ne-cm4n-1)+2   ;width
  1763.  
  1764. ;    fourth menu first item - Count
  1765.  
  1766. cm41:        dc.l    cm42            ;ptr next item
  1767.         dc.w    0            ;rel left edge
  1768.         dc.w    0            ;top edge
  1769.         dc.w    chrw*(cm42ne-cm42n)+2   ;width
  1770.         dc.w    chrh+2            ;height
  1771. cm41f:        dc.w    CHECKIT+ITEMTEXT+ITEMENABLED+HIGHCOMP ;flags
  1772. cm41me:     dc.l    0            ;mutual exclude
  1773.         dc.l    cm41t            ;ptr intui text
  1774.         dc.l    0            ;ptr select fill
  1775.         dc.b    0            ;command
  1776.         dc.b    0            ;word align fill
  1777.         dc.l    0            ;ptr sub item
  1778.         dc.w    0            ;next select
  1779. cm41t:        dc.b    windp,winbp        ;front, back pen
  1780.         dc.b    RP_JAM2         ;draw mode
  1781.         dc.b    0            ;word align fill
  1782.         dc.w    0,0            ;top x,y
  1783.         dc.l    0            ;ptr font
  1784.         dc.l    cm41n            ;ptr text
  1785.         dc.l    0            ;ptr next intui text
  1786. cm41n:        dc.b    '  Count',0             ;item name
  1787. cm41ne:
  1788.  
  1789. ;    fourth menu second item - Save Count
  1790.  
  1791. cm42:        dc.l    cm43            ;ptr next item
  1792.         dc.w    0            ;rel left edge
  1793.         dc.w    chrh+2            ;top edge
  1794.         dc.w    chrw*(cm42ne-cm42n)+2   ;width
  1795.         dc.w    chrh+2            ;height
  1796.         dc.w    ITEMTEXT+ITEMENABLED+HIGHCOMP ;flags
  1797.         dc.l    0            ;mutual exclude
  1798.         dc.l    cm42t            ;ptr intui text
  1799.         dc.l    0            ;ptr select fill
  1800.         dc.b    0            ;command
  1801.         dc.b    0            ;word align fill
  1802.         dc.l    0            ;ptr sub item
  1803.         dc.w    0            ;next select
  1804. cm42t:        dc.b    windp,winbp        ;front, back pen
  1805.         dc.b    RP_JAM2         ;draw mode
  1806.         dc.b    0            ;word align fill
  1807.         dc.w    0,0            ;top x,y
  1808.         dc.l    0            ;ptr font
  1809.         dc.l    cm42n            ;ptr text
  1810.         dc.l    0            ;ptr next intui text
  1811. cm42n:        dc.b    '  Save Count',0        ;item name
  1812. cm42ne:
  1813.  
  1814. ;    fourth menu third item - Trace
  1815.  
  1816. cm43:        dc.l    0            ;ptr next item
  1817.         dc.w    0            ;rel left edge
  1818.         dc.w    2*(chrh+2)              ;top edge
  1819.         dc.w    chrw*(cm42ne-cm42n)+2   ;width
  1820.         dc.w    chrh+2            ;height
  1821. cm43f:        dc.w    CHECKIT+ITEMTEXT+ITEMENABLED+HIGHCOMP ;flags
  1822. cm43me:     dc.l    0            ;mutual exclude
  1823.         dc.l    cm43t            ;ptr intui text
  1824.         dc.l    0            ;ptr select fill
  1825.         dc.b    0            ;command
  1826.         dc.b    0            ;word align fill
  1827.         dc.l    0            ;ptr sub item
  1828.         dc.w    0            ;next select
  1829. cm43t:        dc.b    windp,winbp        ;front, back pen
  1830.         dc.b    RP_JAM2         ;draw mode
  1831.         dc.b    0            ;word align fill
  1832.         dc.w    0,0            ;top x,y
  1833.         dc.l    0            ;ptr font
  1834.         dc.l    cm43n            ;ptr text
  1835.         dc.l    0            ;ptr next intui text
  1836. cm43n:        dc.b    '  Trace',0             ;item name
  1837. cm43ne:
  1838.  
  1839. ;    intuitexts for requesters
  1840. ;    body text, opcode
  1841.  
  1842.         ds.w    0            ;align
  1843. uoreqbt:    dc.b    windp,winbp        ;front, back pen
  1844.         dc.b    RP_JAM2         ;draw mode
  1845.         dc.b    0            ;word align fill
  1846.         dc.w    reqoffx,reqoffy     ;top x,y
  1847.         dc.l    0            ;ptr font
  1848.         dc.l    1$            ;ptr text
  1849.         dc.l    0            ;ptr next intui text
  1850. 1$:        dc.b    'Unimplemented opcode $'
  1851. uoreqbtd:    dc.b    '    ',0
  1852.  
  1853. ;    body text 1, cpm function
  1854.  
  1855.         ds.w    0            ;align
  1856. cereqbt1:    dc.b    windp,winbp        ;front, back pen
  1857.         dc.b    RP_JAM2         ;draw mode
  1858.         dc.b    0            ;word align fill
  1859.         dc.w    reqoffx,reqoffy     ;top x,y
  1860.         dc.l    0            ;ptr font
  1861.         dc.l    1$            ;ptr text
  1862.         dc.l    cereqbt2        ;ptr next intui text
  1863. 1$:        dc.b    'CPM function $'
  1864. cereqbtd2:    dc.b    '  , error $'
  1865. cereqbtd1:    dc.b    '  ',0
  1866.  
  1867. ;    body text 2, cpm function
  1868.  
  1869.         ds.w    0            ;align
  1870. cereqbt2:    dc.b    windp,winbp        ;front, back pen
  1871.         dc.b    RP_JAM2         ;draw mode
  1872.         dc.b    0            ;word align fill
  1873.         dc.w    reqoffx,reqoffy+chrh+2    ;top x,y
  1874.         dc.l    0            ;ptr font
  1875. cereqbt2d:    dc.l    0            ;ptr text, to be set
  1876.         dc.l    0            ;ptr next intui text
  1877.  
  1878. ;    positive text, opcode & cpm function
  1879.  
  1880.         ds.w    0            ;align
  1881. uoreqpt:    dc.b    windp,winbp        ;front, back pen
  1882.         dc.b    RP_JAM2         ;draw mode
  1883.         dc.b    0            ;word align fill
  1884.         dc.w    reqoffx,reqoffy     ;top x,y
  1885.         dc.l    0            ;ptr font
  1886.         dc.l    1$            ;ptr text
  1887.         dc.l    0            ;ptr next intui text
  1888. 1$:        dc.b    'Stop',0
  1889.  
  1890. ;    negative text, opcode & cpm function
  1891.  
  1892.         ds.w    0            ;align
  1893. uoreqnt:    dc.b    windp,winbp        ;front, back pen
  1894.         dc.b    RP_JAM2         ;draw mode
  1895.         dc.b    0            ;word align fill
  1896.         dc.w    reqoffx,reqoffy     ;top x,y
  1897.         dc.l    0            ;ptr font
  1898.         dc.l    1$            ;ptr text
  1899.         dc.l    0            ;ptr next intui text
  1900. 1$:        dc.b    'Halt',0
  1901.  
  1902. ;    library pointers
  1903.  
  1904. libstart:    ds.w    0            ;align
  1905. intbase:    dc.l    0            ;intuition base
  1906. _DOSBase    dc.l    0            ;AmigaDOS base
  1907.         dc.l    $ffffffff        ;last
  1908.  
  1909. ;    window pointers
  1910.  
  1911. winstart:    ds.w    0            ;align
  1912. conwinptr:    dc.l    0            ;ptr console window struct
  1913. z80winptr:    dc.l    0            ;ptr z80 window struct
  1914.         dc.l    $ffffffff        ;last
  1915.  
  1916. ;    table over version pointers, end with ptr=0
  1917.  
  1918. verptrs:    dc.l    czver
  1919.         dc.l    cever
  1920.         dc.l    zekver
  1921.         dc.l    zekcbver
  1922.         dc.l    zekddver
  1923.         dc.l    zekedver
  1924.         dc.l    taskver
  1925.         dc.l    0            ;end
  1926.  
  1927. ;    various
  1928.  
  1929. debug:        dc.b    0            ;non zero durin debug
  1930. glflgs:     dc.b    0            ;global flags
  1931.                         ;0 : z80 stopped
  1932.                         ;1 : z80 opened by z80opcni
  1933.                         ;2 : console waiting
  1934.                         ;3 : new chr in conbuf
  1935.                         ;4 : req on undef esc seq
  1936.                         ;5 : debug count in progress
  1937.                         ;6 : debug trace in progress
  1938. remkey:     dc.l    0            ;ptr for alloc/free remember
  1939.  
  1940. ;    uninitialized data area
  1941. ;    z80 registers
  1942. ;    do not change induvidial order
  1943.  
  1944. z80regstart:    ds.w    0            ;align
  1945. z80af:        ds.w    1
  1946. z80hl:        ds.w    1
  1947. z80de:        ds.w    1
  1948. z80bc:        ds.w    1
  1949. z80sp:        ds.w    1
  1950. z80pc:        ds.w    1
  1951. z80afp:     ds.w    1
  1952. z80hlp:     ds.w    1
  1953. z80dep:     ds.w    1
  1954. z80bcp:     ds.w    1
  1955. z80ix:        ds.w    1
  1956. z80iy:        ds.w    1
  1957. z80regend:                ;last register label
  1958.  
  1959. ;    various
  1960.  
  1961. buffer:     ds.b    buflen        ;scratch use
  1962. ireg:        ds.b    1        ;ireg in z80
  1963. spsave:     ds.l    1        ;save initial sp
  1964. z80pgmptr:    ds.l    1        ;ptr z80 program area
  1965. z80rasptr:    ds.l    1        ;ptr z80 window rasport
  1966. _SysBase:    ds.l    1        ;exec library ptr
  1967.  
  1968.         end
  1969.  
  1970.