Add missing snapshots (batch 9/24)
Browse filesAdds 6000 files from the 129-case snapshot repair. Large cases may span adjacent batches.
Cases touched:
- jotego_jtcores_pr1101
- jotego_jtcores_pr1167
This view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +46 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/asm/z80/TinyBasic_2.0g.asm +1780 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/asm/z80/jtTinyBasic.asm +1789 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/asm/z80/tiny_basic_instructions.pdf +3 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/clean-builds.sh +11 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/conv.m +35 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/cpbeta.sh +141 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/cprbf.sh +30 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/dump.m +8 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/extract2mr.sh +16 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/filechange.sh +87 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/font0.hex +1024 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/font0.pf +0 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/getset.sh +97 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/git-prompt.sh +560 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/hooks/post-commit +5 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/hooks/post-merge +10 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/hooks/pre-commit +19 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/install/jotego_20.04.sh +167 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/install/quartus13_20.04.sh +30 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtbeta +69 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtbin2mr +137 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtbin2sd +177 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtblaster +33 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtcore +408 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtcore-funcs +272 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtcore13 +19 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtcrtcfg.py +160 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtframe +48 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtgood +28 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtioreg.awk +40 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtnet.sh +5 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtreg +30 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtreg-list.sh +21 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtrelease-funcs +239 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtrelease.sh +42 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtsdram +106 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtseed +59 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtsim +556 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtsim-funcs +525 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtsim-funcs-test.sh +81 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtupdate +128 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtutil +30 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/lint-all.sh +74 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/lint-changed.sh +19 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/lint-one.sh +108 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/logo128.png +3 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/setprj.sh +245 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/sim-all-scenes.sh +30 -0
- snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/simunit.sh +165 -0
.gitattributes
CHANGED
|
@@ -806,3 +806,49 @@ Repos/HWE/agents/Lingxi/docs/Lingxi[[:space:]]v1.5[[:space:]]Technical[[:space:]
|
|
| 806 |
Repos/HWE/agents/Lingxi/docs/Lingxi[[:space:]]v2.0[[:space:]]Technical[[:space:]]Report[[:space:]]2026.pdf filter=lfs diff=lfs merge=lfs -text
|
| 807 |
Repos/HWE/agents/Lingxi/imgs/overview_fig.pdf filter=lfs diff=lfs merge=lfs -text
|
| 808 |
patches/esa-tu-darmstadt_tapasco_pr105.patch filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 806 |
Repos/HWE/agents/Lingxi/docs/Lingxi[[:space:]]v2.0[[:space:]]Technical[[:space:]]Report[[:space:]]2026.pdf filter=lfs diff=lfs merge=lfs -text
|
| 807 |
Repos/HWE/agents/Lingxi/imgs/overview_fig.pdf filter=lfs diff=lfs merge=lfs -text
|
| 808 |
patches/esa-tu-darmstadt_tapasco_pr105.patch filter=lfs diff=lfs merge=lfs -text
|
| 809 |
+
snapshots/jotego_jtcores_pr1101/modules/jtframe/asm/z80/tiny_basic_instructions.pdf filter=lfs diff=lfs merge=lfs -text
|
| 810 |
+
snapshots/jotego_jtcores_pr1101/modules/jtframe/doc/93c06.pdf filter=lfs diff=lfs merge=lfs -text
|
| 811 |
+
snapshots/jotego_jtcores_pr1101/modules/jtframe/doc/T48[[:space:]]Integration[[:space:]]Manual.pdf filter=lfs diff=lfs merge=lfs -text
|
| 812 |
+
snapshots/jotego_jtcores_pr1167/cores/aliens/doc/051937_schematics.pdf filter=lfs diff=lfs merge=lfs -text
|
| 813 |
+
snapshots/jotego_jtcores_pr1167/cores/aliens/doc/051960_schematics.pdf filter=lfs diff=lfs merge=lfs -text
|
| 814 |
+
snapshots/jotego_jtcores_pr1167/cores/aliens/doc/052591/k052591_schematics.pdf filter=lfs diff=lfs merge=lfs -text
|
| 815 |
+
snapshots/jotego_jtcores_pr1167/cores/aliens/doc/k051962_schematics.pdf filter=lfs diff=lfs merge=lfs -text
|
| 816 |
+
snapshots/jotego_jtcores_pr1167/cores/aliens/doc/k052109_schematics.pdf filter=lfs diff=lfs merge=lfs -text
|
| 817 |
+
snapshots/jotego_jtcores_pr1167/cores/contra/doc/007121.pdf filter=lfs diff=lfs merge=lfs -text
|
| 818 |
+
snapshots/jotego_jtcores_pr1167/cores/flstory/doc/msm5232.ods filter=lfs diff=lfs merge=lfs -text
|
| 819 |
+
snapshots/jotego_jtcores_pr1167/cores/pinpon/doc/Konami's[[:space:]]Ping[[:space:]]Pong[[:space:]]Report.pdf filter=lfs diff=lfs merge=lfs -text
|
| 820 |
+
snapshots/jotego_jtcores_pr1167/cores/riders/ver/glfgreat/z-tilemap filter=lfs diff=lfs merge=lfs -text
|
| 821 |
+
snapshots/jotego_jtcores_pr1167/cores/riders/ver/glfgreat/z-tiles filter=lfs diff=lfs merge=lfs -text
|
| 822 |
+
snapshots/jotego_jtcores_pr1167/cores/s16b/doc/315-5195_schematics.pdf filter=lfs diff=lfs merge=lfs -text
|
| 823 |
+
snapshots/jotego_jtcores_pr1167/cores/s18/custom/shdancer/epr-12716.b8 filter=lfs diff=lfs merge=lfs -text
|
| 824 |
+
snapshots/jotego_jtcores_pr1167/cores/s18/custom/shdancer/epr-12723.a8 filter=lfs diff=lfs merge=lfs -text
|
| 825 |
+
snapshots/jotego_jtcores_pr1167/cores/s18/custom/shdancer/epr-12773b.a5 filter=lfs diff=lfs merge=lfs -text
|
| 826 |
+
snapshots/jotego_jtcores_pr1167/cores/s18/custom/shdancer/epr-12774b.a6 filter=lfs diff=lfs merge=lfs -text
|
| 827 |
+
snapshots/jotego_jtcores_pr1167/cores/s18/custom/shdancer/epr-12987.a4 filter=lfs diff=lfs merge=lfs -text
|
| 828 |
+
snapshots/jotego_jtcores_pr1167/cores/s18/custom/shdancer/mpr-12712.b1 filter=lfs diff=lfs merge=lfs -text
|
| 829 |
+
snapshots/jotego_jtcores_pr1167/cores/s18/custom/shdancer/mpr-12713.b2 filter=lfs diff=lfs merge=lfs -text
|
| 830 |
+
snapshots/jotego_jtcores_pr1167/cores/s18/custom/shdancer/mpr-12714.b3 filter=lfs diff=lfs merge=lfs -text
|
| 831 |
+
snapshots/jotego_jtcores_pr1167/cores/s18/custom/shdancer/mpr-12715.b4 filter=lfs diff=lfs merge=lfs -text
|
| 832 |
+
snapshots/jotego_jtcores_pr1167/cores/s18/custom/shdancer/mpr-12717.b9 filter=lfs diff=lfs merge=lfs -text
|
| 833 |
+
snapshots/jotego_jtcores_pr1167/cores/s18/custom/shdancer/mpr-12718.b10 filter=lfs diff=lfs merge=lfs -text
|
| 834 |
+
snapshots/jotego_jtcores_pr1167/cores/s18/custom/shdancer/mpr-12719.b11 filter=lfs diff=lfs merge=lfs -text
|
| 835 |
+
snapshots/jotego_jtcores_pr1167/cores/s18/custom/shdancer/mpr-12724.a9 filter=lfs diff=lfs merge=lfs -text
|
| 836 |
+
snapshots/jotego_jtcores_pr1167/cores/s18/custom/shdancer/mpr-12725.a10 filter=lfs diff=lfs merge=lfs -text
|
| 837 |
+
snapshots/jotego_jtcores_pr1167/cores/s18/custom/shdancer/mpr-12726.a11 filter=lfs diff=lfs merge=lfs -text
|
| 838 |
+
snapshots/jotego_jtcores_pr1167/cores/s18/custom/shdancer/shdancbl/ic16 filter=lfs diff=lfs merge=lfs -text
|
| 839 |
+
snapshots/jotego_jtcores_pr1167/cores/s18/custom/shdancer/shdancbl/ic17 filter=lfs diff=lfs merge=lfs -text
|
| 840 |
+
snapshots/jotego_jtcores_pr1167/cores/s18/custom/shdancer/shdancbl/ic18 filter=lfs diff=lfs merge=lfs -text
|
| 841 |
+
snapshots/jotego_jtcores_pr1167/cores/s18/custom/shdancer/shdancbl/ic2 filter=lfs diff=lfs merge=lfs -text
|
| 842 |
+
snapshots/jotego_jtcores_pr1167/cores/s18/custom/shdancer/shdancbl/ic3 filter=lfs diff=lfs merge=lfs -text
|
| 843 |
+
snapshots/jotego_jtcores_pr1167/cores/s18/custom/shdancer/shdancbl/ic4 filter=lfs diff=lfs merge=lfs -text
|
| 844 |
+
snapshots/jotego_jtcores_pr1167/cores/s18/custom/shdancer/shdancer1/epr-12720.a4 filter=lfs diff=lfs merge=lfs -text
|
| 845 |
+
snapshots/jotego_jtcores_pr1167/cores/s18/custom/shdancer/shdancer1/epr-12771b.a5 filter=lfs diff=lfs merge=lfs -text
|
| 846 |
+
snapshots/jotego_jtcores_pr1167/cores/s18/custom/shdancer/shdancer1/epr-12772b.a6 filter=lfs diff=lfs merge=lfs -text
|
| 847 |
+
snapshots/jotego_jtcores_pr1167/cores/s18/custom/shdancer/shdancerj/epr-12721b.a5 filter=lfs diff=lfs merge=lfs -text
|
| 848 |
+
snapshots/jotego_jtcores_pr1167/cores/s18/custom/shdancer/shdancerj/epr-12722b.a6 filter=lfs diff=lfs merge=lfs -text
|
| 849 |
+
snapshots/jotego_jtcores_pr1167/cores/simson/doc/053251.pdf filter=lfs diff=lfs merge=lfs -text
|
| 850 |
+
snapshots/jotego_jtcores_pr1167/cores/simson/doc/k053260_schematics.PDF filter=lfs diff=lfs merge=lfs -text
|
| 851 |
+
snapshots/jotego_jtcores_pr1167/doc/mame.xml filter=lfs diff=lfs merge=lfs -text
|
| 852 |
+
snapshots/jotego_jtcores_pr1167/modules/jtframe/asm/z80/tiny_basic_instructions.pdf filter=lfs diff=lfs merge=lfs -text
|
| 853 |
+
snapshots/jotego_jtcores_pr1167/modules/jtframe/doc/93c06.pdf filter=lfs diff=lfs merge=lfs -text
|
| 854 |
+
snapshots/jotego_jtcores_pr1167/modules/jtframe/doc/T48[[:space:]]Integration[[:space:]]Manual.pdf filter=lfs diff=lfs merge=lfs -text
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/asm/z80/TinyBasic_2.0g.asm
ADDED
|
@@ -0,0 +1,1780 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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ATED
|
| 8 |
+
; TO INTEL MNEMONICS
|
| 9 |
+
; BY ROGER RAUSKOLB
|
| 10 |
+
; 10 OCTOBER,1976
|
| 11 |
+
;
|
| 12 |
+
; MODIFIED AND TRANSLATED
|
| 13 |
+
; TO ZILOG MNEMONICS
|
| 14 |
+
; BY DOUG GABBARD
|
| 15 |
+
; www.retrodepot.net
|
| 16 |
+
;
|
| 17 |
+
; RELEASED TO THE PUBLIC
|
| 18 |
+
; 10 OCTOBER,2017
|
| 19 |
+
; YEAH, 41 YEARS LATER....
|
| 20 |
+
;
|
| 21 |
+
; @COPYLEFT
|
| 22 |
+
; ALL WRONGS RESERVED
|
| 23 |
+
;
|
| 24 |
+
;*************************************************************
|
| 25 |
+
; This code is derived from the original 8080 Tiny Basic.
|
| 26 |
+
; It was first compiled in 8080 Mnemonics, then disassembled
|
| 27 |
+
; into Zilog Mnemonics. And then checked against the original
|
| 28 |
+
; to ensure accuracy. It was then partially enhanced with z80
|
| 29 |
+
; specific code. And once done, it was then modified to work
|
| 30 |
+
; with the G80-S Micro Computer. However, that portion of the
|
| 31 |
+
; code has been left out in order to make this code a little
|
| 32 |
+
; more portable. There are only three routines that one needs
|
| 33 |
+
; to write, and specifing the serial port's I/O address, in
|
| 34 |
+
; order to make this version work with your own DIY computer.
|
| 35 |
+
; Those routines can be found at the end of the source code.
|
| 36 |
+
;
|
| 37 |
+
; I hope you find good use for this relic. However, I would
|
| 38 |
+
; ask that if you do find use for it, please put a reference
|
| 39 |
+
; to me in your work. And please, distribute freely.
|
| 40 |
+
;*************************************************************
|
| 41 |
+
|
| 42 |
+
SerialPort: EQU 00H ;This is for your I/0
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
SPACE: EQU 020H ; Space
|
| 46 |
+
TAB: EQU 09H ; HORIZONTAL TAB
|
| 47 |
+
CTRLC: EQU 03H ; Control "C"
|
| 48 |
+
CTRLG: EQU 07H ; Control "G"
|
| 49 |
+
BKSP: EQU 08H ; Back space
|
| 50 |
+
LF: EQU 0AH ; Line feed
|
| 51 |
+
CS: EQU 0CH ; Clear screen
|
| 52 |
+
CR: EQU 0DH ; Carriage return
|
| 53 |
+
CTRLO: EQU 0FH ; Control "O"
|
| 54 |
+
CTRLQ: EQU 011H ; Control "Q"
|
| 55 |
+
CTRLR: EQU 012H ; Control "R"
|
| 56 |
+
CTRLS: EQU 013H ; Control "S"
|
| 57 |
+
CTRLU: EQU 015H ; Control "U"
|
| 58 |
+
ESC: EQU 01BH ; Escape
|
| 59 |
+
DEL: EQU 07FH ; Delete
|
| 60 |
+
|
| 61 |
+
STACK: EQU 0FFFFH ; STACK
|
| 62 |
+
OCSW: EQU 08000H ;SWITCH FOR OUTPUT
|
| 63 |
+
CURRNT: EQU OCSW+1 ;POINTS FOR OUTPUT
|
| 64 |
+
STKGOS: EQU OCSW+3 ;SAVES SP IN 'GOSUB'
|
| 65 |
+
VARNXT: EQU OCSW+5 ;TEMP STORAGE
|
| 66 |
+
STKINP: EQU OCSW+7 ;SAVES SP IN 'INPUT'
|
| 67 |
+
LOPVAR: EQU OCSW+9 ;'FOR' LOOP SAVE AREA
|
| 68 |
+
LOPINC: EQU OCSW+11 ;INCREMENT
|
| 69 |
+
LOPLMT: EQU OCSW+13 ;LIMIT
|
| 70 |
+
LOPLN: EQU OCSW+15 ;LINE NUMBER
|
| 71 |
+
LOPPT: EQU OCSW+17 ;TEXT POINTER
|
| 72 |
+
RANPNT: EQU OCSW+19 ;RANDOM NUMBER POINTER
|
| 73 |
+
TXTUNF: EQU OCSW+21 ;->UNFILLED TEXT AREA
|
| 74 |
+
TXTBGN: EQU OCSW+23 ;TEXT SAVE AREA BEGINS
|
| 75 |
+
|
| 76 |
+
TXTEND: EQU 0FF00H ;TEXT SAVE AREA ENDS
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
;*************************************************************
|
| 80 |
+
; *** ZERO PAGE SUBROUTINES ***
|
| 81 |
+
;
|
| 82 |
+
; THE Z80 INSTRUCTION SET ALLOWS FOR 8 ROUTINES IN LOW MEMORY
|
| 83 |
+
; THAT MAY BE CALLED BY RST 00H, 08H, 10H, 18H, 20H, 28H, 30H,
|
| 84 |
+
; AND 38H. THIS IS A ONE BYTE INSTRUCTION, AND IS FUNCTIONALLY
|
| 85 |
+
; SIMILAR TO THE THREE BYTE INSTRUCTION 'CALL XXXX'. TINY BASIC
|
| 86 |
+
; WILL USE THE RST INSTRUCTION FOR THE 7 MOST FREQUENTLY USED
|
| 87 |
+
; SUBROUTINES. TWO OTHER SUBROUTINES (CRLF & TSTNUM) ARE ALSO
|
| 88 |
+
; IN THIS SECTION. THEY CAN BE REACHED WITH 'CALL'.
|
| 89 |
+
;*************************************************************
|
| 90 |
+
|
| 91 |
+
DWA: MACRO WHERE
|
| 92 |
+
DB (WHERE >> 8) + 128
|
| 93 |
+
DB WHERE & 0FFH
|
| 94 |
+
ENDM
|
| 95 |
+
|
| 96 |
+
ORG 0000H
|
| 97 |
+
|
| 98 |
+
START:
|
| 99 |
+
LD SP,STACK ;*** COLD START ***
|
| 100 |
+
LD A,0FFH
|
| 101 |
+
JP INIT
|
| 102 |
+
|
| 103 |
+
RST08: EX (SP),HL ;*** TSTC OR RST 08H ***
|
| 104 |
+
RST 28H ;IGNORE BLANKS AND
|
| 105 |
+
CP (HL) ;TEST CHARACTER
|
| 106 |
+
JP TC1 ;REST OF THIS IS AT TC1
|
| 107 |
+
|
| 108 |
+
CRLF:
|
| 109 |
+
LD A,CR ;*** CRLF ***
|
| 110 |
+
|
| 111 |
+
RST10: PUSH AF ;*** OUTC OR RST 10H ***
|
| 112 |
+
LD A,(OCSW) ;PRINT CHARACTER ONLY
|
| 113 |
+
OR A ;IF OCSW SWITCH IS ON
|
| 114 |
+
JP OUTC ;REST OF THIS AT OUTC
|
| 115 |
+
|
| 116 |
+
RST18: CALL EXPR2 ;*** EXPR OR RST 18H ***
|
| 117 |
+
PUSH HL ;EVALUATE AN EXPRESSION
|
| 118 |
+
JP EXPR1 ;REST OF IT AT EXPR1
|
| 119 |
+
DB 'W'
|
| 120 |
+
|
| 121 |
+
RST20: LD A,H ;*** COMP OR RST 20H ***
|
| 122 |
+
CP D ;COMPARE HL WITH DE
|
| 123 |
+
RET NZ ;RETURN CORRECT C AND
|
| 124 |
+
LD A,L ;Z FLAGS
|
| 125 |
+
CP E ;BUT OLD A IS LOST
|
| 126 |
+
RET
|
| 127 |
+
DB 'AN'
|
| 128 |
+
|
| 129 |
+
SS1:
|
| 130 |
+
RST28: LD A,(DE) ;*** IGNBLK/RST 28H ***
|
| 131 |
+
CP 20H ;IGNORE BLANKS
|
| 132 |
+
RET NZ ;IN TEXT (WHERE DE->)
|
| 133 |
+
INC DE ;AND RETURN THE FIRST
|
| 134 |
+
JP SS1 ;NON-BLANK CHAR. IN A
|
| 135 |
+
|
| 136 |
+
RST30: POP AF ;*** FINISH/RST 30H ***
|
| 137 |
+
CALL FIN ;CHECK END OF COMMAND
|
| 138 |
+
JP QWHAT ;PRINT "WHAT?" IF WRONG
|
| 139 |
+
DB 'G'
|
| 140 |
+
|
| 141 |
+
RST38: RST 28H ;*** TSTV OR RST 38H ***
|
| 142 |
+
SUB 40H ;TEST VARIABLES
|
| 143 |
+
RET C ;C:NOT A VARIABLE
|
| 144 |
+
JR NZ,TV1 ;NOT "@" ARRAY
|
| 145 |
+
INC DE ;IT IS THE "@" ARRAY
|
| 146 |
+
CALL PARN ;@ SHOULD BE FOLLOWED
|
| 147 |
+
ADD HL,HL ;BY (EXPR) AS ITS INDEX
|
| 148 |
+
JR C,QHOW ;IS INDEX TOO BIG?
|
| 149 |
+
PUSH DE ;WILL IT OVERWRITE
|
| 150 |
+
EX DE,HL ;TEXT?
|
| 151 |
+
CALL SIZE ;FIND SIZE OF FREE
|
| 152 |
+
RST 20H ;AND CHECK THAT
|
| 153 |
+
JP C,ASORRY ;IF SO, SAY "SORRY"
|
| 154 |
+
LD HL,VARBGN ;IF NOT GET ADDRESS
|
| 155 |
+
CALL SUBDE ;OF @(EXPR) AND PUT IT
|
| 156 |
+
POP DE ;IN HL
|
| 157 |
+
RET ;C FLAG IS CLEARED
|
| 158 |
+
|
| 159 |
+
TV1:
|
| 160 |
+
CP 1BH ;NOT @, IS IT A TO Z?
|
| 161 |
+
CCF ;IF NOT RETURN C FLAG
|
| 162 |
+
RET C
|
| 163 |
+
INC DE ;IF A THROUGH Z
|
| 164 |
+
LD HL,VARBGN ;COMPUTE ADDRESS OF
|
| 165 |
+
RLCA ;THAT VARIABLE
|
| 166 |
+
ADD A,L ;AND RETURN IT IN HL
|
| 167 |
+
LD L,A ;WITH C FLAG CLEARED
|
| 168 |
+
LD A,00H
|
| 169 |
+
ADC A,H
|
| 170 |
+
LD H,A
|
| 171 |
+
RET
|
| 172 |
+
|
| 173 |
+
TC1:
|
| 174 |
+
INC HL ;COMPARE THE BYTE THAT
|
| 175 |
+
JR Z,TC2 ;FOLLOWS THE RST INST.
|
| 176 |
+
PUSH BC ;WITH THE TEXT (DE->)
|
| 177 |
+
LD C,(HL) ;IF NOT =, ADD THE 2ND
|
| 178 |
+
LD B,00H ;BYTE THAT FOLLOWS THE
|
| 179 |
+
ADD HL,BC ;RST TO THE OLD PC
|
| 180 |
+
POP BC ;I.E., DO A RELATIVE
|
| 181 |
+
DEC DE ;JUMP IF NOT =
|
| 182 |
+
|
| 183 |
+
TC2:
|
| 184 |
+
INC DE ;IF =, SKIP THOSE BYTES
|
| 185 |
+
INC HL ;AND CONTINUE
|
| 186 |
+
EX (SP),HL
|
| 187 |
+
RET
|
| 188 |
+
|
| 189 |
+
TSTNUM:
|
| 190 |
+
LD HL,0000H ;*** TSTNUM ***
|
| 191 |
+
LD B,H ;TEST IF THE TEXT IS
|
| 192 |
+
RST 28H ;A NUMBER
|
| 193 |
+
|
| 194 |
+
TN1:
|
| 195 |
+
CP 30H ;IF NOT, RETURN 0 IN
|
| 196 |
+
RET C ;B AND HL
|
| 197 |
+
CP 3AH ;IF NUMBERS, CONVERT
|
| 198 |
+
RET NC ;TO BINARY IN HL AND
|
| 199 |
+
LD A,0F0H ;SET B TO # OF DIGITS
|
| 200 |
+
AND H ;IF H>255, THERE IS NO
|
| 201 |
+
JR NZ,QHOW ;ROOM FOR NEXT DIGIT
|
| 202 |
+
INC B ;B COUNTS # OF DIGITS
|
| 203 |
+
PUSH BC
|
| 204 |
+
LD B,H ;HL=10*HL+(NEW DIGIT)
|
| 205 |
+
LD C,L
|
| 206 |
+
ADD HL,HL ;WHERE 10* IS DONE BY
|
| 207 |
+
ADD HL,HL ;SHIFT AND ADD
|
| 208 |
+
ADD HL,BC
|
| 209 |
+
ADD HL,HL
|
| 210 |
+
LD A,(DE) ;AND (DIGIT) IS FROM
|
| 211 |
+
INC DE ;STRIPPING THE ASCII
|
| 212 |
+
AND 0FH ;CODE
|
| 213 |
+
ADD A,L
|
| 214 |
+
LD L,A
|
| 215 |
+
LD A,00H
|
| 216 |
+
ADC A,H
|
| 217 |
+
LD H,A
|
| 218 |
+
POP BC
|
| 219 |
+
LD A,(DE) ;DO THIS DIGIT AFTER
|
| 220 |
+
JP P,TN1 ;DIGIT. S SAYS OVERFLOW
|
| 221 |
+
|
| 222 |
+
QHOW:
|
| 223 |
+
PUSH DE ;*** ERROR "HOW?" ***
|
| 224 |
+
AHOW:
|
| 225 |
+
LD DE,HOW
|
| 226 |
+
JP ERROR_ROUTINE
|
| 227 |
+
|
| 228 |
+
|
| 229 |
+
HOW: DB "HOW?",CR
|
| 230 |
+
OK: DB "OK",CR
|
| 231 |
+
WHAT: DB "WHAT?",CR
|
| 232 |
+
SORRY: DB "SORRY",CR
|
| 233 |
+
|
| 234 |
+
;*************************************************************
|
| 235 |
+
;
|
| 236 |
+
; *** MAIN ***
|
| 237 |
+
;
|
| 238 |
+
; THIS IS THE MAIN LOOP THAT COLLECTS THE TINY BASIC PROGRAM
|
| 239 |
+
; AND STORES IT IN THE MEMORY.
|
| 240 |
+
;
|
| 241 |
+
; AT START, IT PRINTS OUT "(CR)OK(CR)", AND INITIALIZES THE
|
| 242 |
+
; STACK AND SOME OTHER INTERNAL VARIABLES. THEN IT PROMPTS
|
| 243 |
+
; ">" AND READS A LINE. IF THE LINE STARTS WITH A NON-ZERO
|
| 244 |
+
; NUMBER, THIS NUMBER IS THE LINE NUMBER. THE LINE NUMBER
|
| 245 |
+
; (IN 16 BIT BINARY) AND THE REST OF THE LINE (INCLUDING CR)
|
| 246 |
+
; IS STORED IN THE MEMORY. IF A LINE WITH THE SAME LINE
|
| 247 |
+
; NUMBER IS ALREADY THERE, IT IS REPLACED BY THE NEW ONE. IF
|
| 248 |
+
; THE REST OF THE LINE CONSISTS OF A CR ONLY, IT IS NOT STORED
|
| 249 |
+
; AND ANY EXISTING LINE WITH THE SAME LINE NUMBER IS DELETED.
|
| 250 |
+
;
|
| 251 |
+
; AFTER A LINE IS INSERTED, REPLACED, OR DELETED, THE PROGRAM
|
| 252 |
+
; LOOPS BACK AND ASKS FOR ANOTHER LINE. THIS LOOP WILL BE
|
| 253 |
+
; TERMINATED WHEN IT READS A LINE WITH ZERO OR NO LINE
|
| 254 |
+
; NUMBER; AND CONTROL IS TRANSFERED TO "DIRECT".
|
| 255 |
+
;
|
| 256 |
+
; TINY BASIC PROGRAM SAVE AREA STARTS AT THE MEMORY LOCATION
|
| 257 |
+
; LABELED "TXTBGN" AND ENDS AT "TXTEND". WE ALWAYS FILL THIS
|
| 258 |
+
; AREA STARTING AT "TXTBGN", THE UNFILLED PORTION IS POINTED
|
| 259 |
+
; BY THE CONTENT OF A MEMORY LOCATION LABELED "TXTUNF".
|
| 260 |
+
;
|
| 261 |
+
; THE MEMORY LOCATION "CURRNT" POINTS TO THE LINE NUMBER
|
| 262 |
+
; THAT IS CURRENTLY BEING INTERPRETED. WHILE WE ARE IN
|
| 263 |
+
; THIS LOOP OR WHILE WE ARE INTERPRETING A DIRECT COMMAND
|
| 264 |
+
; (SEE NEXT SECTION). "CURRNT" SHOULD POINT TO A 0.
|
| 265 |
+
;*************************************************************
|
| 266 |
+
|
| 267 |
+
RSTART:
|
| 268 |
+
LD SP,STACK
|
| 269 |
+
|
| 270 |
+
ST1:
|
| 271 |
+
CALL CRLF ;AND JUMP TO HERE
|
| 272 |
+
LD DE,OK ;DE->STRING
|
| 273 |
+
SUB A ;A=0
|
| 274 |
+
CALL PRTSTG ;PRINT STRING UNTIL CR
|
| 275 |
+
LD HL,ST2+1 ;LITERAL 0
|
| 276 |
+
LD (CURRNT),HL ;CURRENT->LINE # = 0
|
| 277 |
+
|
| 278 |
+
ST2:
|
| 279 |
+
LD HL,0000H
|
| 280 |
+
LD (LOPVAR),HL
|
| 281 |
+
LD (STKGOS),HL
|
| 282 |
+
|
| 283 |
+
ST3:
|
| 284 |
+
LD A,'>' ;PROMPT '>' AND
|
| 285 |
+
CALL GETLN ;READ A LINE
|
| 286 |
+
PUSH DE ;DE->END OF LINE
|
| 287 |
+
LD DE,BUFFER ;DE->BEGINNING OF LINE
|
| 288 |
+
CALL TSTNUM ;TEST IF IT IS A NUMBER
|
| 289 |
+
RST 28H
|
| 290 |
+
LD A,H ;HL=VALUE OF THE # OR
|
| 291 |
+
OR L ;0 IF NO # WAS FOUND
|
| 292 |
+
POP BC ;BC->END OF LINE
|
| 293 |
+
JP Z,DIRECT
|
| 294 |
+
DEC DE ;BACKUP DE AND SAVE
|
| 295 |
+
LD A,H ;VALUE OF LINE # THERE
|
| 296 |
+
LD (DE),A
|
| 297 |
+
DEC DE
|
| 298 |
+
LD A,L
|
| 299 |
+
LD (DE),A
|
| 300 |
+
PUSH BC ;BC,DE->BEGIN, END
|
| 301 |
+
PUSH DE
|
| 302 |
+
LD A,C
|
| 303 |
+
SUB E
|
| 304 |
+
|
| 305 |
+
PUSH AF ;A=# OF BYTES IN LINE
|
| 306 |
+
CALL FNDLN ;FIND THIS LINE IN SAVE
|
| 307 |
+
PUSH DE ;AREA, DE->SAVE AREA
|
| 308 |
+
JR NZ,ST4 ;NZ:NOT FOUND, INSERT
|
| 309 |
+
PUSH DE ;Z:FOUND, DELETE IT
|
| 310 |
+
CALL FNDNXT ;FIND NEXT LINE
|
| 311 |
+
;DE->NEXT LINE
|
| 312 |
+
POP BC ;BC->LINE TO BE DELETED
|
| 313 |
+
LD HL,(TXTUNF) ;HL->UNFILLED SAVE AREA
|
| 314 |
+
CALL MVUP ;MOVE UP TO DELETE
|
| 315 |
+
LD H,B ;TXTUNF->UNFILLED ARA
|
| 316 |
+
LD L,C
|
| 317 |
+
LD (TXTUNF),HL ;UPDATE
|
| 318 |
+
|
| 319 |
+
ST4:
|
| 320 |
+
POP BC ;GET READY TO INSERT
|
| 321 |
+
LD HL,(TXTUNF) ;BUT FIRST CHECK IF
|
| 322 |
+
POP AF ;THE LENGTH OF NEW LINE
|
| 323 |
+
PUSH HL ;IS 3 (LINE # AND CR)
|
| 324 |
+
CP 03H ;THEN DO NOT INSERT
|
| 325 |
+
JR Z,RSTART ;MUST CLEAR THE STACK
|
| 326 |
+
ADD A,L ;COMPUTE NEW TXTUNF
|
| 327 |
+
LD L,A
|
| 328 |
+
LD A,00H
|
| 329 |
+
ADC A,H
|
| 330 |
+
LD H,A ;HL->NEW UNFILLED AREA
|
| 331 |
+
LD DE,TXTEND ;CHECK TO SEE IF THERE
|
| 332 |
+
RST 20H ;IS ENOUGH SPACE
|
| 333 |
+
JP NC,QSORRY ;SORRY, NO ROOM FOR IT
|
| 334 |
+
LD (TXTUNF),HL ;OK, UPDATE TXTUNF
|
| 335 |
+
POP DE ;DE->OLD UNFILLED AREA
|
| 336 |
+
CALL MVDOWN
|
| 337 |
+
POP DE ;DE->BEGIN, HL->END
|
| 338 |
+
POP HL
|
| 339 |
+
CALL MVUP ;MOVE NEW LINE TO SAVE
|
| 340 |
+
JR ST3 ;AREA
|
| 341 |
+
|
| 342 |
+
;*************************************************************
|
| 343 |
+
;
|
| 344 |
+
; WHAT FOLLOWS IS THE CODE TO EXECUTE DIRECT AND STATEMENT
|
| 345 |
+
; COMMANDS. CONTROL IS TRANSFERED TO THESE POINTS VIA THE
|
| 346 |
+
; COMMAND TABLE LOOKUP CODE OF 'DIRECT' AND 'EXEC' IN LAST
|
| 347 |
+
; SECTION. AFTER THE COMMAND IS EXECUTED, CONTROL IS
|
| 348 |
+
; TRANSFERED TO OTHERS SECTIONS AS FOLLOWS:
|
| 349 |
+
;
|
| 350 |
+
; FOR 'LIST', 'NEW', AND 'STOP': GO BACK TO 'RSTART'
|
| 351 |
+
; FOR 'RUN': GO EXECUTE THE FIRST STORED LINE IF ANY, ELSE
|
| 352 |
+
; GO BACK TO 'RSTART'.
|
| 353 |
+
; FOR 'GOTO' AND 'GOSUB': GO EXECUTE THE TARGET LINE.
|
| 354 |
+
; FOR 'RETURN' AND 'NEXT': GO BACK TO SAVED RETURN LINE.
|
| 355 |
+
; FOR ALL OTHERS: IF 'CURRENT' -> 0, GO TO 'RSTART', ELSE
|
| 356 |
+
; GO EXECUTE NEXT COMMAND. (THIS IS DONE IN 'FINISH'.)
|
| 357 |
+
;*************************************************************
|
| 358 |
+
;
|
| 359 |
+
; *** NEW *** STOP *** RUN (& FRIENDS) *** & GOTO ***
|
| 360 |
+
;
|
| 361 |
+
; 'NEW(CR)' SETS 'TXTUNF' TO POINT TO 'TXTBGN'
|
| 362 |
+
;
|
| 363 |
+
; 'STOP(CR)' GOES BACK TO 'RSTART'
|
| 364 |
+
;
|
| 365 |
+
; 'RUN(CR)' FINDS THE FIRST STORED LINE, STORE ITS ADDRESS (IN
|
| 366 |
+
; 'CURRENT'), AND START EXECUTE IT. NOTE THAT ONLY THOSE
|
| 367 |
+
; COMMANDS IN TAB2 ARE LEGAL FOR STORED PROGRAM.
|
| 368 |
+
;
|
| 369 |
+
; THERE ARE 3 MORE ENTRIES IN 'RUN':
|
| 370 |
+
; 'RUNNXL' FINDS NEXT LINE, STORES ITS ADDR. AND EXECUTES IT.
|
| 371 |
+
; 'RUNTSL' STORES THE ADDRESS OF THIS LINE AND EXECUTES IT.
|
| 372 |
+
; 'RUNSML' CONTINUES THE EXECUTION ON SAME LINE.
|
| 373 |
+
;
|
| 374 |
+
; 'GOTO EXPR(CR)' EVALUATES THE EXPRESSION, FIND THE TARGET
|
| 375 |
+
; LINE, AND JUMP TO 'RUNTSL' TO DO IT.
|
| 376 |
+
;*************************************************************
|
| 377 |
+
|
| 378 |
+
NEW:
|
| 379 |
+
CALL ENDCHK ;*** NEW(CR) ***
|
| 380 |
+
LD HL,TXTBGN
|
| 381 |
+
LD (TXTUNF),HL
|
| 382 |
+
STOP:
|
| 383 |
+
CALL ENDCHK ;*** STOP(CR) ***
|
| 384 |
+
JP RSTART
|
| 385 |
+
RUN:
|
| 386 |
+
CALL ENDCHK ;*** RUN(CR) ***
|
| 387 |
+
LD DE,TXTBGN ;FIRST SAVED LINE
|
| 388 |
+
RUNNXL:
|
| 389 |
+
LD HL,00H ;*** RUNNXL ***
|
| 390 |
+
CALL FNDLP ;FIND WHATEVER LINE #
|
| 391 |
+
JP C,RSTART ;C:PASSED TXTUNF, QUIT
|
| 392 |
+
RUNTSL:
|
| 393 |
+
EX DE,HL ;*** RUNTSL ***
|
| 394 |
+
LD (CURRNT),HL ;SET 'CURRENT'->LINE #
|
| 395 |
+
EX DE,HL
|
| 396 |
+
INC DE ;BUMP PASS LINE #
|
| 397 |
+
INC DE
|
| 398 |
+
RUNSML:
|
| 399 |
+
CALL CHKIO ;*** RUNSML ***
|
| 400 |
+
LD HL,TAB2-1 ;FIND COMMAND IN TAB2
|
| 401 |
+
JP EXEC ;AND EXECUTE IT
|
| 402 |
+
GOTO:
|
| 403 |
+
RST 18H ;*** GOTO EXPR ***
|
| 404 |
+
PUSH DE ;SAVE FOR ERROR ROUTINE
|
| 405 |
+
CALL ENDCHK ;MUST FIND A CR
|
| 406 |
+
CALL FNDLN ;FIND THE TARGET LINE
|
| 407 |
+
JP NZ,AHOW ;NO SUCH LINE #
|
| 408 |
+
POP AF ;CLEAR THE PUSH DE
|
| 409 |
+
JR RUNTSL ;GO DO IT
|
| 410 |
+
|
| 411 |
+
;*************************************************************
|
| 412 |
+
;
|
| 413 |
+
; *** LIST *** & PRINT ***
|
| 414 |
+
;
|
| 415 |
+
; LIST HAS TWO FORMS:
|
| 416 |
+
; 'LIST(CR)' LISTS ALL SAVED LINES
|
| 417 |
+
; 'LIST #(CR)' START LIST AT THIS LINE #
|
| 418 |
+
; YOU CAN STOP THE LISTING BY CONTROL C KEY
|
| 419 |
+
;
|
| 420 |
+
; PRINT COMMAND IS 'PRINT ....;' OR 'PRINT ....(CR)'
|
| 421 |
+
; WHERE '....' IS A LIST OF EXPRESIONS, FORMATS, BACK-
|
| 422 |
+
; ARROWS, AND STRINGS. THESE ITEMS ARE SEPERATED BY COMMAS.
|
| 423 |
+
;
|
| 424 |
+
; A FORMAT IS A POUND SIGN FOLLOWED BY A NUMBER. IT CONTROLS
|
| 425 |
+
; THE NUMBER OF SPACES THE VALUE OF A EXPRESION IS GOING TO
|
| 426 |
+
; BE PRINTED. IT STAYS EFFECTIVE FOR THE REST OF THE PRINT
|
| 427 |
+
; COMMAND UNLESS CHANGED BY ANOTHER FORMAT. IF NO FORMAT IS
|
| 428 |
+
; SPECIFIED, 6 POSITIONS WILL BE USED.
|
| 429 |
+
;
|
| 430 |
+
; A STRING IS QUOTED IN A PAIR OF SINGLE QUOTES OR A PAIR OF
|
| 431 |
+
; DOUBLE QUOTES.
|
| 432 |
+
;
|
| 433 |
+
; A BACK-ARROW MEANS GENERATE A (CR) WITHOUT (LF)
|
| 434 |
+
;
|
| 435 |
+
; A (CRLF) IS GENERATED AFTER THE ENTIRE LIST HAS BEEN
|
| 436 |
+
; PRINTED OR IF THE LIST IS A NULL LIST. HOWEVER IF THE LIST
|
| 437 |
+
; ENDED WITH A COMMA, NO (CRLF) IS GENERATED.
|
| 438 |
+
;*************************************************************
|
| 439 |
+
|
| 440 |
+
LIST:
|
| 441 |
+
CALL TSTNUM ;TEST IF THERE IS A #
|
| 442 |
+
CALL ENDCHK ;IF NO # WE GET A 0
|
| 443 |
+
CALL FNDLN ;FIND THIS OR NEXT LINE
|
| 444 |
+
LS1:
|
| 445 |
+
JP C,RSTART ;C:PASSED TXTUNF
|
| 446 |
+
CALL PRTLN ;PRINT THE LINE
|
| 447 |
+
CALL CHKIO ;STOP IF HIT CONTROL-C
|
| 448 |
+
CALL FNDLP ;FIND NEXT LINE
|
| 449 |
+
JR LS1 ;AND LOOP BACK
|
| 450 |
+
PRINT:
|
| 451 |
+
LD C,06H ;C = # OF SPACES
|
| 452 |
+
RST 08H ;F NULL LIST & ";"
|
| 453 |
+
DB 3BH
|
| 454 |
+
DB PR2-$-1
|
| 455 |
+
CALL CRLF ;GIVE CR-LF AND
|
| 456 |
+
JR RUNSML ;CONTINUE SAME LINE
|
| 457 |
+
PR2:
|
| 458 |
+
RST 08H ;IF NULL LIST (CR)
|
| 459 |
+
DB CR
|
| 460 |
+
DB PR0-$-1
|
| 461 |
+
CALL CRLF ;ALSO GIVE CR-LF AND
|
| 462 |
+
JR RUNNXL ;GO TO NEXT LINE
|
| 463 |
+
PR0:
|
| 464 |
+
RST 08H ;ELSE IS IT FORMAT?
|
| 465 |
+
DB '#'
|
| 466 |
+
DB PR1-$-1
|
| 467 |
+
RST 18H ;YES, EVALUATE EXPR.
|
| 468 |
+
LD C,L ;AND SAVE IT IN C
|
| 469 |
+
JR PR3 ;LOOK FOR MORE TO PRINT
|
| 470 |
+
PR1:
|
| 471 |
+
CALL QTSTG ;OR IS IT A STRING?
|
| 472 |
+
JR PR8 ;IF NOT, MUST BE EXPR.
|
| 473 |
+
PR3:
|
| 474 |
+
RST 08H ;IF ",", GO FIND NEXT
|
| 475 |
+
DB ','
|
| 476 |
+
DB PR6-$-1
|
| 477 |
+
CALL FIN ;IN THE LIST.
|
| 478 |
+
JR PR0 ;LIST CONTINUES
|
| 479 |
+
PR6:
|
| 480 |
+
CALL CRLF ;LIST ENDS
|
| 481 |
+
RST 30H
|
| 482 |
+
PR8:
|
| 483 |
+
RST 18H ;EVALUATE THE EXPR
|
| 484 |
+
PUSH BC
|
| 485 |
+
CALL PRTNUM ;PRINT THE VALUE
|
| 486 |
+
POP BC
|
| 487 |
+
JR PR3 ;MORE TO PRINT?
|
| 488 |
+
|
| 489 |
+
;*************************************************************
|
| 490 |
+
;
|
| 491 |
+
; *** GOSUB *** & RETURN ***
|
| 492 |
+
;
|
| 493 |
+
; 'GOSUB EXPR;' OR 'GOSUB EXPR (CR)' IS LIKE THE 'GOTO'
|
| 494 |
+
; COMMAND, EXCEPT THAT THE CURRENT TEXT POINTER, STACK POINTER
|
| 495 |
+
; ETC. ARE SAVE SO THAT EXECUTION CAN BE CONTINUED AFTER THE
|
| 496 |
+
; SUBROUTINE 'RETURN'. IN ORDER THAT 'GOSUB' CAN BE NESTED
|
| 497 |
+
; (AND EVEN RECURSIVE), THE SAVE AREA MUST BE STACKED.
|
| 498 |
+
; THE STACK POINTER IS SAVED IN 'STKGOS', THE OLD 'STKGOS' IS
|
| 499 |
+
; SAVED IN THE STACK. IF WE ARE IN THE MAIN ROUTINE, 'STKGOS'
|
| 500 |
+
; IS ZERO (THIS WAS DONE BY THE "MAIN" SECTION OF THE CODE),
|
| 501 |
+
; BUT WE STILL SAVE IT AS A FLAG FOR NO FURTHER 'RETURN'S.
|
| 502 |
+
;
|
| 503 |
+
; 'RETURN(CR)' UNDOS EVERYTHING THAT 'GOSUB' DID, AND THUS
|
| 504 |
+
; RETURN THE EXECUTION TO THE COMMAND AFTER THE MOST RECENT
|
| 505 |
+
; 'GOSUB'. IF 'STKGOS' IS ZERO, IT INDICATES THAT WE
|
| 506 |
+
; NEVER HAD A 'GOSUB' AND IS THUS AN ERROR.
|
| 507 |
+
;*************************************************************
|
| 508 |
+
|
| 509 |
+
GOSUB:
|
| 510 |
+
CALL PUSHA ;SAVE THE CURRENT "FOR"
|
| 511 |
+
RST 18H ;PARAMETERS
|
| 512 |
+
PUSH DE ;AND TEXT POINTER
|
| 513 |
+
CALL FNDLN ;FIND THE TARGET LINE
|
| 514 |
+
JP NZ,AHOW ;NOT THERE. SAY "HOW?"
|
| 515 |
+
LD HL,(CURRNT) ;FOUND IT, SAVE OLD.
|
| 516 |
+
PUSH HL ;'CURRNT' OLD 'STKGOS'
|
| 517 |
+
LD HL,(STKGOS)
|
| 518 |
+
PUSH HL
|
| 519 |
+
LD HL,0000H ;AND LOAD NEW ONES
|
| 520 |
+
LD (LOPVAR),HL
|
| 521 |
+
ADD HL,SP
|
| 522 |
+
LD (STKGOS),HL
|
| 523 |
+
JP RUNTSL ;THEN RUN THAT LINE
|
| 524 |
+
RETURN:
|
| 525 |
+
CALL ENDCHK ;THERE MUST BE A CR
|
| 526 |
+
LD HL,(STKGOS) ;OLD STACK POINTER
|
| 527 |
+
LD A,H ;0 MEANS NOT EXIST
|
| 528 |
+
OR L
|
| 529 |
+
JP Z,QWHAT ;SO, WE SAY: "WHAT?"
|
| 530 |
+
LD SP,HL ;ELSE, RESTORE IT
|
| 531 |
+
POP HL
|
| 532 |
+
LD (STKGOS),HL ;AND THE OLD "STKGOS"
|
| 533 |
+
POP HL
|
| 534 |
+
LD (CURRNT),HL ;AND THE OLD 'CURRNT'
|
| 535 |
+
POP DE ;OLD TEXT POINTER
|
| 536 |
+
CALL POPA ;OLD "FOR" PARAMETERS
|
| 537 |
+
RST 30H ;AND WE ARE BACK HOME
|
| 538 |
+
|
| 539 |
+
;*************************************************************
|
| 540 |
+
;
|
| 541 |
+
; *** FOR *** & NEXT ***
|
| 542 |
+
;
|
| 543 |
+
; 'FOR' HAS TWO FORMS:
|
| 544 |
+
; 'FOR VAR=EXP1 TO EXP2 STEP EXP3' AND 'FOR VAR=EXP1 TO EXP2'
|
| 545 |
+
; THE SECOND FORM MEANS THE SAME THING AS THE FIRST FORM WITH
|
| 546 |
+
; EXP3=1. (I.E., WITH A STEP OF +1.)
|
| 547 |
+
; TBI WILL FIND THE VARIABLE VAR, AND SET ITS VALUE TO THE
|
| 548 |
+
; CURRENT VALUE OF EXP1. IT ALSO EVALUATES EXP2 AND EXP3
|
| 549 |
+
; AND SAVE ALL THESE TOGETHER WITH THE TEXT POINTER ETC. IN
|
| 550 |
+
; THE 'FOR' SAVE AREA, WHICH CONSISTS OF 'LOPVAR', 'LOPINC',
|
| 551 |
+
; 'LOPLMT', 'LOPLN', AND 'LOPPT'. IF THERE IS ALREADY SOME-
|
| 552 |
+
; THING IN THE SAVE AREA (THIS IS INDICATED BY A NON-ZERO
|
| 553 |
+
; 'LOPVAR'), THEN THE OLD SAVE AREA IS SAVED IN THE STACK
|
| 554 |
+
; BEFORE THE NEW ONE OVERWRITES IT.
|
| 555 |
+
; TBI WILL THEN DIG IN THE STACK AND FIND OUT IF THIS SAME
|
| 556 |
+
; VARIABLE WAS USED IN ANOTHER CURRENTLY ACTIVE 'FOR' LOOP.
|
| 557 |
+
; IF THAT IS THE CASE, THEN THE OLD 'FOR' LOOP IS DEACTIVATED.
|
| 558 |
+
; (PURGED FROM THE STACK..)
|
| 559 |
+
;
|
| 560 |
+
; 'NEXT VAR' SERVES AS THE LOGICAL (NOT NECESSARILLY PHYSICAL)
|
| 561 |
+
; END OF THE 'FOR' LOOP. THE CONTROL VARIABLE VAR. IS CHECKED
|
| 562 |
+
; WITH THE 'LOPVAR'. IF THEY ARE NOT THE SAME, TBI DIGS IN
|
| 563 |
+
; THE STACK TO FIND THE RIGHT ONE AND PURGES ALL THOSE THAT
|
| 564 |
+
; DID NOT MATCH. EITHER WAY, TBI THEN ADDS THE 'STEP' TO
|
| 565 |
+
; THAT VARIABLE AND CHECK THE RESULT WITH THE LIMIT. IF IT
|
| 566 |
+
; IS WITHIN THE LIMIT, CONTROL LOOPS BACK TO THE COMMAND
|
| 567 |
+
; FOLLOWING THE 'FOR'. IF OUTSIDE THE LIMIT, THE SAVE AREA
|
| 568 |
+
; IS PURGED AND EXECUTION CONTINUES.
|
| 569 |
+
;*************************************************************
|
| 570 |
+
|
| 571 |
+
FOR:
|
| 572 |
+
CALL PUSHA ;SAVE THE OLD SAVE AREA
|
| 573 |
+
CALL SETVAL ;SET THE CONTROL VAR.
|
| 574 |
+
DEC HL ;HL IS ITS ADDRESS
|
| 575 |
+
LD (LOPVAR),HL ;SAVE THAT
|
| 576 |
+
LD HL,TAB5-1 ;USE 'EXEC' TO LOOK
|
| 577 |
+
JP EXEC ;FOR THE WORK 'TO'
|
| 578 |
+
FR1:
|
| 579 |
+
RST 18H ;EVALUATE THE LIMITE
|
| 580 |
+
LD (LOPLMT),HL ;SAVE THAT
|
| 581 |
+
LD HL,TAB6-1 ;USE 'EXEC' TO LOOK
|
| 582 |
+
JP EXEC ;FOR THE WORD 'STEP'
|
| 583 |
+
FR2:
|
| 584 |
+
RST 18H ;FOUND IT, GET STEP
|
| 585 |
+
JR FR4
|
| 586 |
+
FR3:
|
| 587 |
+
LD HL,0001H ;NOT FOUND, SET TO 1
|
| 588 |
+
FR4:
|
| 589 |
+
LD (LOPINC),HL ;SAVE THAT TOO
|
| 590 |
+
FR5:
|
| 591 |
+
LD HL,(CURRNT) ;SAVE CURRENT LINE #
|
| 592 |
+
LD (LOPLN),HL
|
| 593 |
+
EX DE,HL ;AND TEXT POINTER
|
| 594 |
+
LD (LOPPT),HL
|
| 595 |
+
LD BC,0AH ;DIG INTO STACK TO
|
| 596 |
+
LD HL,(LOPVAR) ;FIND 'LOPVAR'
|
| 597 |
+
EX DE,HL
|
| 598 |
+
LD H,B
|
| 599 |
+
LD L,B ;HL=0 NOW
|
| 600 |
+
ADD HL,SP ;HERE IS THE STACK
|
| 601 |
+
DB 3EH ;DISASSEMBLY SAID "ld a,09h"
|
| 602 |
+
FR7:
|
| 603 |
+
ADD HL,BC ;EACH LEVEL IS 10 DEEP - DIS = 09
|
| 604 |
+
LD A,(HL) ;GET THAT OLD 'LOPVAR'
|
| 605 |
+
INC HL
|
| 606 |
+
OR (HL)
|
| 607 |
+
JR Z,FR8 ;0 SAYS NO MORE IN IT
|
| 608 |
+
LD A,(HL)
|
| 609 |
+
DEC HL
|
| 610 |
+
CP D ;SAME AS THIS ONE?
|
| 611 |
+
JR NZ,FR7
|
| 612 |
+
LD A,(HL) ;THE OTHER HALF?
|
| 613 |
+
CP E
|
| 614 |
+
JR NZ,FR7
|
| 615 |
+
EX DE,HL ;YES, FOUND ONE
|
| 616 |
+
LD HL,0000H
|
| 617 |
+
ADD HL,SP ;TRY TO MOVE SP
|
| 618 |
+
LD B,H
|
| 619 |
+
LD C,L
|
| 620 |
+
LD HL,000AH
|
| 621 |
+
ADD HL,DE
|
| 622 |
+
CALL MVDOWN ;AND PURGE 10 WORDS
|
| 623 |
+
LD SP,HL ;IN THE STACK
|
| 624 |
+
FR8:
|
| 625 |
+
LD HL,(LOPPT) ;JOB DONE, RESTORE DE
|
| 626 |
+
EX DE,HL
|
| 627 |
+
RST 30H ;AND CONTINUE
|
| 628 |
+
;
|
| 629 |
+
NEXT:
|
| 630 |
+
RST 38H ;GET ADDRESS OF VAR.
|
| 631 |
+
JP C,QWHAT ;NO VARIABLE, "WHAT?"
|
| 632 |
+
LD (VARNXT),HL ;YES, SAVE IT
|
| 633 |
+
NX0:
|
| 634 |
+
PUSH DE ;SAVE TEXT POINTER
|
| 635 |
+
EX DE,HL
|
| 636 |
+
LD HL,(LOPVAR) ;GET VAR. IN 'FOR'
|
| 637 |
+
LD A,H
|
| 638 |
+
OR L ;0 SAYS NEVER HAD ONE
|
| 639 |
+
JP Z,AWHAT ;SO WE ASK: "WHAT?"
|
| 640 |
+
RST 20H ;ELSE WE CHECK THEM
|
| 641 |
+
JR Z,NX3 ;OK, THEY AGREE
|
| 642 |
+
POP DE ;NO, LET'S SEE
|
| 643 |
+
CALL POPA ;PURGE CURRENT LOOP
|
| 644 |
+
LD HL,(VARNXT) ;AND POP ONE LEVEL
|
| 645 |
+
JR NX0 ;GO CHECK AGAIN
|
| 646 |
+
NX3:
|
| 647 |
+
LD E,(HL) ;COME HERE WHEN AGREED
|
| 648 |
+
INC HL
|
| 649 |
+
LD D,(HL) ;DE=VALUE OF VAR.
|
| 650 |
+
LD HL,(LOPINC)
|
| 651 |
+
PUSH HL
|
| 652 |
+
LD A,H
|
| 653 |
+
XOR D
|
| 654 |
+
LD A,D
|
| 655 |
+
ADD HL,DE ;ADD ONE STEP
|
| 656 |
+
JP M,NX4
|
| 657 |
+
XOR H
|
| 658 |
+
JP M,NX5
|
| 659 |
+
NX4:
|
| 660 |
+
EX DE,HL
|
| 661 |
+
LD HL,(LOPVAR) ;PUT IT BACK
|
| 662 |
+
LD (HL),E
|
| 663 |
+
INC HL
|
| 664 |
+
LD (HL),D
|
| 665 |
+
LD HL,(LOPLMT) ;HL->LIMIT
|
| 666 |
+
POP AF ;OLD HL
|
| 667 |
+
OR A
|
| 668 |
+
JP P,NX1 ;STEP > 0
|
| 669 |
+
EX DE,HL ;STEP < 0
|
| 670 |
+
NX1:
|
| 671 |
+
CALL CKHLDE ;COMPARE WITH LIMIT
|
| 672 |
+
POP DE ;RESTORE TEXT POINTER
|
| 673 |
+
JR C,NX2 ;OUTSIDE LIMIT
|
| 674 |
+
LD HL,(LOPLN) ;WITHIN LIMIT, GO
|
| 675 |
+
LD (CURRNT),HL ;BACK TO THE SAVED
|
| 676 |
+
LD HL,(LOPPT) ;'CURRNT' AND TEXT
|
| 677 |
+
EX DE,HL ;POINTER
|
| 678 |
+
RST 30H
|
| 679 |
+
NX5:
|
| 680 |
+
POP HL
|
| 681 |
+
POP DE
|
| 682 |
+
NX2:
|
| 683 |
+
CALL POPA ;PURGE THIS LOOP
|
| 684 |
+
RST 30H
|
| 685 |
+
|
| 686 |
+
;*************************************************************
|
| 687 |
+
;
|
| 688 |
+
; *** REM *** IF *** INPUT *** & LET (& DEFLT) ***
|
| 689 |
+
;
|
| 690 |
+
; 'REM' CAN BE FOLLOWED BY ANYTHING AND IS IGNORED BY TBI.
|
| 691 |
+
; TBI TREATS IT LIKE AN 'IF' WITH A FALSE CONDITION.
|
| 692 |
+
;
|
| 693 |
+
; 'IF' IS FOLLOWED BY AN EXPR. AS A CONDITION AND ONE OR MORE
|
| 694 |
+
; COMMANDS (INCLUDING OTHER 'IF'S) SEPERATED BY SEMI-COLONS.
|
| 695 |
+
; NOTE THAT THE WORD 'THEN' IS NOT USED. TBI EVALUATES THE
|
| 696 |
+
; EXPR. IF IT IS NON-ZERO, EXECUTION CONTINUES. IF THE
|
| 697 |
+
; EXPR. IS ZERO, THE COMMANDS THAT FOLLOWS ARE IGNORED AND
|
| 698 |
+
; EXECUTION CONTINUES AT THE NEXT LINE.
|
| 699 |
+
;
|
| 700 |
+
; 'INPUT' COMMAND IS LIKE THE 'PRINT' COMMAND, AND IS FOLLOWED
|
| 701 |
+
; BY A LIST OF ITEMS. IF THE ITEM IS A STRING IN SINGLE OR
|
| 702 |
+
; DOUBLE QUOTES, OR IS A BACK-ARROW, IT HAS THE SAME EFFECT AS
|
| 703 |
+
; IN 'PRINT'. IF AN ITEM IS A VARIABLE, THIS VARIABLE NAME IS
|
| 704 |
+
; PRINTED OUT FOLLOWED BY A COLON. THEN TBI WAITS FOR AN
|
| 705 |
+
; EXPR. TO BE TYPED IN. THE VARIABLE IS THEN SET TO THE
|
| 706 |
+
; VALUE OF THIS EXPR. IF THE VARIABLE IS PROCEDED BY A STRING
|
| 707 |
+
; (AGAIN IN SINGLE OR DOUBLE QUOTES), THE STRING WILL BE
|
| 708 |
+
; PRINTED FOLLOWED BY A COLON. TBI THEN WAITS FOR INPUT EXPR.
|
| 709 |
+
; AND SET THE VARIABLE TO THE VALUE OF THE EXPR.
|
| 710 |
+
;
|
| 711 |
+
; IF THE INPUT EXPR. IS INVALID, TBI WILL PRINT "WHAT?",
|
| 712 |
+
; "HOW?" OR "SORRY" AND REPRINT THE PROMPT AND REDO THE INPUT.
|
| 713 |
+
; THE EXECUTION WILL NOT TERMINATE UNLESS YOU TYPE CONTROL-C.
|
| 714 |
+
; THIS IS HANDLED IN 'INPERR'.
|
| 715 |
+
;
|
| 716 |
+
; 'LET' IS FOLLOWED BY A LIST OF ITEMS SEPERATED BY COMMAS.
|
| 717 |
+
; EACH ITEM CONSISTS OF A VARIABLE, AN EQUAL SIGN, AND AN EXPR.
|
| 718 |
+
; TBI EVALUATES THE EXPR. AND SET THE VARIABLE TO THAT VALUE.
|
| 719 |
+
; TBI WILL ALSO HANDLE 'LET' COMMAND WITHOUT THE WORD 'LET'.
|
| 720 |
+
; THIS IS DONE BY 'DEFLT'.
|
| 721 |
+
;*************************************************************
|
| 722 |
+
|
| 723 |
+
REM:
|
| 724 |
+
LD HL,0000H ;*** REM ***
|
| 725 |
+
DB 3EH ;THIS IS LIKE 'IF 0'
|
| 726 |
+
IFF:
|
| 727 |
+
RST 18H ;*** IF ***
|
| 728 |
+
LD A,H ;IS THE EXPR.=0?
|
| 729 |
+
OR L
|
| 730 |
+
JP NZ,RUNSML ;NO, CONTINUE
|
| 731 |
+
CALL FNDSKP ;YES, SKIP REST OF LINE
|
| 732 |
+
JP NC,RUNTSL ;AND RUN THE NEXT LINE
|
| 733 |
+
JP RSTART ;IF NO NEXT, RE-START
|
| 734 |
+
INPERR:
|
| 735 |
+
LD HL,(STKINP) ;*** INPERR ***
|
| 736 |
+
LD SP,HL ;RESTORE OLD SP
|
| 737 |
+
POP HL ;AND OLD 'CURRNT'
|
| 738 |
+
LD (CURRNT),HL
|
| 739 |
+
POP DE ;AND OLD TEXT POINTER
|
| 740 |
+
POP DE ;REDO INPUT
|
| 741 |
+
INPUT: ;*** INPUT ***
|
| 742 |
+
IP1:
|
| 743 |
+
PUSH DE ;SAVE IN CASE OF ERROR
|
| 744 |
+
CALL QTSTG ;IS NEXT ITEM A STRING?
|
| 745 |
+
JR IP2 ;NO
|
| 746 |
+
RST 38H ;YES, BUT FOLLOWED BY A
|
| 747 |
+
JR C,IP4 ;VARIABLE? NO.
|
| 748 |
+
JR IP3 ;YES. INPUT VARIABLE
|
| 749 |
+
IP2:
|
| 750 |
+
PUSH DE ;SAVE FOR 'PRTSTG'
|
| 751 |
+
RST 38H ;MUST BE VARIABLE NOW
|
| 752 |
+
JP C,QWHAT ;"WHAT?" IT IS NOT?
|
| 753 |
+
LD A,(DE) ;GET READY FOR 'PRTSTR'
|
| 754 |
+
LD C,A
|
| 755 |
+
SUB A
|
| 756 |
+
LD (DE),A
|
| 757 |
+
POP DE
|
| 758 |
+
CALL PRTSTG ;PRINT STRING AS PROMPT
|
| 759 |
+
LD A,C ;RESTORE TEXT
|
| 760 |
+
DEC DE
|
| 761 |
+
LD (DE),A
|
| 762 |
+
IP3:
|
| 763 |
+
PUSH DE ;SAVE TEXT POINTER
|
| 764 |
+
EX DE,HL
|
| 765 |
+
LD HL,(CURRNT) ;ALSO SAVE 'CURRNT'
|
| 766 |
+
PUSH HL
|
| 767 |
+
LD HL,IP1 ;A NEGATIVE NUMBER
|
| 768 |
+
LD (CURRNT),HL ;AS A FLAG
|
| 769 |
+
LD HL,0000H ;SAVE SP TOO
|
| 770 |
+
ADD HL,SP
|
| 771 |
+
LD (STKINP),HL
|
| 772 |
+
PUSH DE ;OLD HL
|
| 773 |
+
LD A,3AH ;PRINT THIS TOO
|
| 774 |
+
CALL GETLN ;AND GET A LINE
|
| 775 |
+
LD DE,BUFFER ;POINTS TO BUFFER
|
| 776 |
+
RST 18H ;EVALUATE INPUT
|
| 777 |
+
NOP ;CAN BE 'CALL ENDCHK'
|
| 778 |
+
NOP
|
| 779 |
+
NOP
|
| 780 |
+
POP DE ;OK,GET OLD HL
|
| 781 |
+
EX DE,HL
|
| 782 |
+
LD (HL),E ;SAVE VALUE IN VAR.
|
| 783 |
+
INC HL
|
| 784 |
+
LD (HL),D
|
| 785 |
+
POP HL ;GET OLD 'CURRNT'
|
| 786 |
+
LD (CURRNT),HL
|
| 787 |
+
POP DE ;AND OLD TEXT POINTER
|
| 788 |
+
IP4:
|
| 789 |
+
POP AF ;PURGE JUNK IN STACK
|
| 790 |
+
RST 08H ;IS NEXT CH. ','?
|
| 791 |
+
DB ','
|
| 792 |
+
DB IP5-$-1
|
| 793 |
+
JR IP1 ;YES, MORE ITEMS.
|
| 794 |
+
IP5:
|
| 795 |
+
RST 30H
|
| 796 |
+
DEFLT:
|
| 797 |
+
LD A,(DE) ;*** DEFLT ***
|
| 798 |
+
CP CR ;EMPTY LINE IS OK
|
| 799 |
+
JR Z,LT1 ;ELSE IT IS 'LET'
|
| 800 |
+
LET:
|
| 801 |
+
CALL SETVAL ;*** LET ***
|
| 802 |
+
RST 08H ;SET VALUE TO VAR
|
| 803 |
+
DB ',' ;---DISASSEMBLE = INC L
|
| 804 |
+
DB LT1-$-1 ;---DISASSEMBLE = INC BC
|
| 805 |
+
JR LET ;ITEM BY ITEM
|
| 806 |
+
LT1:
|
| 807 |
+
RST 30H ;UNTIL FINISH
|
| 808 |
+
;*************************************************************
|
| 809 |
+
;
|
| 810 |
+
; *** EXPR ***
|
| 811 |
+
;
|
| 812 |
+
; 'EXPR' EVALUATES ARITHMETICAL OR LOGICAL EXPRESSIONS.
|
| 813 |
+
; <EXPR>::<EXPR2>
|
| 814 |
+
; <EXPR2><REL.OP.><EXPR2>
|
| 815 |
+
; WHERE <REL.OP.> IS ONE OF THE OPERATORS IN TAB8 AND THE
|
| 816 |
+
; RESULT OF THESE OPERATIONS IS 1 IF TRUE AND 0 IF FALSE.
|
| 817 |
+
; <EXPR2>::=(+ OR -)<EXPR3>(+ OR -<EXPR3>)(....)
|
| 818 |
+
; WHERE () ARE OPTIONAL AND (....) ARE OPTIONAL REPEATS.
|
| 819 |
+
; <EXPR3>::=<EXPR4>(* OR /><EXPR4>)(....)
|
| 820 |
+
; <EXPR4>::=<VARIABLE>
|
| 821 |
+
; <FUNCTION>
|
| 822 |
+
; (<EXPR>)
|
| 823 |
+
; <EXPR> IS RECURSIVE SO THAT VARIABLE '@' CAN HAVE AN <EXPR>
|
| 824 |
+
; AS INDEX, FUNCTIONS CAN HAVE AN <EXPR> AS ARGUMENTS, AND
|
| 825 |
+
; <EXPR4> CAN BE AN <EXPR> IN PARANTHESE.
|
| 826 |
+
;*************************************************************
|
| 827 |
+
|
| 828 |
+
EXPR1:
|
| 829 |
+
LD HL,TAB8-1 ;LOOKUP REL.OP.
|
| 830 |
+
JP EXEC ;GO DO IT
|
| 831 |
+
XP11:
|
| 832 |
+
CALL XP18 ;REL.OP.">="
|
| 833 |
+
RET C ;NO, RETURN HL=0
|
| 834 |
+
LD L,A ;YES, RETURN HL=1
|
| 835 |
+
RET
|
| 836 |
+
XP12:
|
| 837 |
+
CALL XP18 ;REL.OP."#"
|
| 838 |
+
RET Z ;FALSE, RETURN HL=0
|
| 839 |
+
LD L,A ;TRUE, RETURN HL=1
|
| 840 |
+
RET
|
| 841 |
+
XP13:
|
| 842 |
+
CALL XP18 ;REL.OP.">"
|
| 843 |
+
RET Z ;FALSE
|
| 844 |
+
RET C ;ALSO FALSE, HL=0
|
| 845 |
+
LD L,A ;TRUE, HL=1
|
| 846 |
+
RET
|
| 847 |
+
XP14:
|
| 848 |
+
CALL XP18 ;REL.OP."<="
|
| 849 |
+
LD L,A ;SET HL=1
|
| 850 |
+
RET Z ;REL. TRUE, RETURN
|
| 851 |
+
RET C
|
| 852 |
+
LD L,H ;ELSE SET HL=0
|
| 853 |
+
RET
|
| 854 |
+
XP15:
|
| 855 |
+
CALL XP18 ;REL.OP."="
|
| 856 |
+
RET NZ ;FALSE, RETURN HL=0
|
| 857 |
+
LD L,A ;ELSE SET HL=1
|
| 858 |
+
RET
|
| 859 |
+
XP16:
|
| 860 |
+
CALL XP18 ;REL.OP."<"
|
| 861 |
+
RET NC ;FALSE, RETURN HL=0
|
| 862 |
+
LD L,A ;ELSE SET HL=1
|
| 863 |
+
RET
|
| 864 |
+
XP17:
|
| 865 |
+
POP HL ;NOT .REL.OP
|
| 866 |
+
RET ;RETURN HL=<EXPR2>
|
| 867 |
+
XP18:
|
| 868 |
+
LD A,C ;SUBROUTINE FOR ALL
|
| 869 |
+
POP HL ;REL.OP.'S
|
| 870 |
+
POP BC
|
| 871 |
+
PUSH HL ;REVERSE TOP OF STACK
|
| 872 |
+
PUSH BC
|
| 873 |
+
LD C,A
|
| 874 |
+
CALL EXPR2 ;GET 2ND <EXPR2>
|
| 875 |
+
EX DE,HL ;VALUE IN DE NOW
|
| 876 |
+
EX (SP),HL ;1ST <EXPR2> IN HL
|
| 877 |
+
CALL CKHLDE ;COMPARE 1ST WITH 2ND
|
| 878 |
+
POP DE ;RESTORE TEXT POINTER
|
| 879 |
+
LD HL,0000H ;SET HL=0, A=1
|
| 880 |
+
LD A,01H
|
| 881 |
+
RET
|
| 882 |
+
EXPR2:
|
| 883 |
+
RST 08H ;NEGATIVE SIGN?
|
| 884 |
+
DB '-'
|
| 885 |
+
DB XP21-$-1
|
| 886 |
+
LD HL,0000H ;YES, FAKE '0-'
|
| 887 |
+
JR XP26 ;TREAT LIKE SUBTRACT
|
| 888 |
+
XP21:
|
| 889 |
+
RST 08H ;POSITIVE SIGN? IGNORE
|
| 890 |
+
DB '+'
|
| 891 |
+
DB XP22-$-1
|
| 892 |
+
XP22:
|
| 893 |
+
CALL EXPR3 ;1ST <EXPR3>
|
| 894 |
+
XP23:
|
| 895 |
+
RST 08H ;ADD?
|
| 896 |
+
DB '+'
|
| 897 |
+
DB XP25-$-1
|
| 898 |
+
PUSH HL ;YES, SAVE VALUE
|
| 899 |
+
CALL EXPR3 ;GET 2ND <EXPR3>
|
| 900 |
+
XP24:
|
| 901 |
+
EX DE,HL ;2ND IN DE
|
| 902 |
+
EX (SP),HL ;1ST IN HL
|
| 903 |
+
LD A,H ;COMPARE SIGN
|
| 904 |
+
XOR D
|
| 905 |
+
LD A,D
|
| 906 |
+
ADD HL,DE
|
| 907 |
+
POP DE ;RESTORE TEXT POINTER
|
| 908 |
+
JP M,XP23 ;1ST AND 2ND SIGN DIFFER
|
| 909 |
+
XOR H ;1ST AND 2ND SIGN EQUAL
|
| 910 |
+
JP P,XP23 ;SO IS RESULT
|
| 911 |
+
JP QHOW ;ELSE WE HAVE OVERFLOW
|
| 912 |
+
XP25:
|
| 913 |
+
RST 08H ;SUBTRACT?
|
| 914 |
+
DB '-'
|
| 915 |
+
DB XP42-$-1
|
| 916 |
+
XP26:
|
| 917 |
+
PUSH HL ;YES, SAVE 1ST <EXPR3>
|
| 918 |
+
CALL EXPR3 ;GET 2ND <EXPR3>
|
| 919 |
+
CALL CHGSGN ;NEGATE
|
| 920 |
+
JR XP24 ;AND ADD THEM
|
| 921 |
+
;
|
| 922 |
+
EXPR3:
|
| 923 |
+
CALL EXPR4 ;GET 1ST <EXPR4>
|
| 924 |
+
XP31:
|
| 925 |
+
RST 08H ;MULTIPLY?
|
| 926 |
+
DB '*'
|
| 927 |
+
DB XP34-$-1
|
| 928 |
+
PUSH HL ;YES, SAVE 1ST
|
| 929 |
+
CALL EXPR4 ;AND GET 2ND <EXPR4>
|
| 930 |
+
LD B,00H ;CLEAR B FOR SIGN
|
| 931 |
+
CALL CHKSGN ;CHECK SIGN
|
| 932 |
+
EX (SP),HL ;1ST IN HL
|
| 933 |
+
CALL CHKSGN ;CHECK SIGN OF 1ST
|
| 934 |
+
EX DE,HL
|
| 935 |
+
EX (SP),HL
|
| 936 |
+
LD A,H ;IS HL > 255 ?
|
| 937 |
+
OR A
|
| 938 |
+
JR Z,XP32 ;NO
|
| 939 |
+
LD A,D ;YES, HOW ABOUT DE
|
| 940 |
+
OR D
|
| 941 |
+
EX DE,HL ;PUT SMALLER IN HL
|
| 942 |
+
JP NZ,AHOW ;ALSO >, WILL OVERFLOW
|
| 943 |
+
XP32:
|
| 944 |
+
LD A,L ;THIS IS DUMB
|
| 945 |
+
LD HL,0000H ;CLEAR RESULT
|
| 946 |
+
OR A ;ADD AND COUNT
|
| 947 |
+
JR Z,XP35
|
| 948 |
+
XP33:
|
| 949 |
+
ADD HL,DE
|
| 950 |
+
JP C,AHOW ;OVERFLOW
|
| 951 |
+
DEC A
|
| 952 |
+
JR NZ,XP33
|
| 953 |
+
JR XP35 ;FINISHED
|
| 954 |
+
XP34:
|
| 955 |
+
RST 08H ;DIVIDE?
|
| 956 |
+
DB '/'
|
| 957 |
+
DB XP42-$-1
|
| 958 |
+
PUSH HL ;YES, SAVE 1ST <EXPR4>
|
| 959 |
+
CALL EXPR4 ;AND GET THE SECOND ONE
|
| 960 |
+
LD B,00H ;CLEAR B FOR SIGN
|
| 961 |
+
CALL CHKSGN ;CHECK SIGN OF 2ND
|
| 962 |
+
EX (SP),HL ;GET 1ST IN HL
|
| 963 |
+
CALL CHKSGN ;CHECK SIGN OF 1ST
|
| 964 |
+
EX DE,HL
|
| 965 |
+
EX (SP),HL
|
| 966 |
+
EX DE,HL
|
| 967 |
+
LD A,D ;DIVIDE BY 0?
|
| 968 |
+
OR E
|
| 969 |
+
JP Z,AHOW ;SAY "HOW?"
|
| 970 |
+
PUSH BC ;ELSE SAVE SIGN
|
| 971 |
+
CALL DIVIDE ;USE SUBROUTINE
|
| 972 |
+
LD H,B ;RESULT IN HL NOW
|
| 973 |
+
LD L,C
|
| 974 |
+
POP BC ;GET SIGN BACK
|
| 975 |
+
XP35:
|
| 976 |
+
POP DE ;AND TEXT POINTER
|
| 977 |
+
LD A,H ;HL MUST BE +
|
| 978 |
+
OR A
|
| 979 |
+
JP M,QHOW ;ELSE IT IS OVERFLOW
|
| 980 |
+
LD A,B
|
| 981 |
+
OR A
|
| 982 |
+
CALL M,CHGSGN ;CHANGE SIGN IF NEEDED
|
| 983 |
+
JR XP31 ;LOOK FOR MORE TERMS
|
| 984 |
+
EXPR4:
|
| 985 |
+
LD HL,TAB4-1 ;FIND FUNCTION IN TAB4
|
| 986 |
+
JP EXEC ;AND GO DO IT
|
| 987 |
+
XP40:
|
| 988 |
+
RST 38H ;NO, NOT A FUNCTION
|
| 989 |
+
JR C,XP41 ;NOR A VARIABLE
|
| 990 |
+
LD A,(HL) ;VARIABLE
|
| 991 |
+
INC HL
|
| 992 |
+
LD H,(HL) ;VALUE IN HL
|
| 993 |
+
LD L,A
|
| 994 |
+
RET
|
| 995 |
+
XP41:
|
| 996 |
+
CALL TSTNUM ;OR IS IT A NUMBER
|
| 997 |
+
LD A,B ;# OF DIGIT
|
| 998 |
+
OR A
|
| 999 |
+
RET NZ ;OK
|
| 1000 |
+
PARN:
|
| 1001 |
+
RST 08H
|
| 1002 |
+
DB '('
|
| 1003 |
+
DB XP43-$-1
|
| 1004 |
+
RST 18H ;"(EXPR)"
|
| 1005 |
+
RST 08H
|
| 1006 |
+
DB ')'
|
| 1007 |
+
DB XP43-$-1
|
| 1008 |
+
XP42:
|
| 1009 |
+
RET
|
| 1010 |
+
XP43:
|
| 1011 |
+
JP QWHAT ;ELSE SAY: "WHAT?"
|
| 1012 |
+
RND:
|
| 1013 |
+
CALL PARN ;*** RND(EXPR) ***
|
| 1014 |
+
LD A,H ;EXPR MUST BE +
|
| 1015 |
+
OR A
|
| 1016 |
+
JP M,QHOW
|
| 1017 |
+
OR L ;AND NON-ZERO
|
| 1018 |
+
JP Z,QHOW
|
| 1019 |
+
PUSH DE ;SAVE BOTH
|
| 1020 |
+
PUSH HL
|
| 1021 |
+
LD HL,(RANPNT) ;GET MEMORY AS RANDOM
|
| 1022 |
+
LD DE,LSTROM ;NUMBER
|
| 1023 |
+
RST 20H
|
| 1024 |
+
JR C,RA1 ;WRAP AROUND IF LAST
|
| 1025 |
+
LD HL,START
|
| 1026 |
+
RA1:
|
| 1027 |
+
LD E,(HL)
|
| 1028 |
+
INC HL
|
| 1029 |
+
LD D,(HL)
|
| 1030 |
+
LD (RANPNT),HL
|
| 1031 |
+
POP HL
|
| 1032 |
+
EX DE,HL
|
| 1033 |
+
PUSH BC
|
| 1034 |
+
CALL DIVIDE ;RND (N)=MOD(M,N)+1
|
| 1035 |
+
POP BC
|
| 1036 |
+
POP DE
|
| 1037 |
+
INC HL
|
| 1038 |
+
RET
|
| 1039 |
+
ABS:
|
| 1040 |
+
CALL PARN ;*** ABS (EXPR) ***
|
| 1041 |
+
DEC DE
|
| 1042 |
+
CALL CHKSGN ;CHECK SIGN
|
| 1043 |
+
INC DE
|
| 1044 |
+
RET
|
| 1045 |
+
SIZE:
|
| 1046 |
+
LD HL,(TXTUNF) ;*** SIZE ***
|
| 1047 |
+
PUSH DE ;GET THE NUMBER OF FREE
|
| 1048 |
+
EX DE,HL ;BYTES BETWEEN 'TXTUNF'
|
| 1049 |
+
LD HL,VARBGN ;AND 'VARBGN'
|
| 1050 |
+
CALL SUBDE
|
| 1051 |
+
POP DE
|
| 1052 |
+
RET
|
| 1053 |
+
;*************************************************************
|
| 1054 |
+
;
|
| 1055 |
+
; *** DIVIDE *** SUBDE *** CHKSGN *** CHGSGN *** & CKHLDE ***
|
| 1056 |
+
;
|
| 1057 |
+
; 'DIVIDE' DIVIDES HL BY DE, RESULT IN BC, REMAINDER IN HL
|
| 1058 |
+
;
|
| 1059 |
+
; 'SUBDE' SUBSTRACTS DE FROM HL
|
| 1060 |
+
;
|
| 1061 |
+
; 'CHKSGN' CHECKS SIGN OF HL. IF +, NO CHANGE. IF -, CHANGE
|
| 1062 |
+
; SIGN AND FLIP SIGN OF B.
|
| 1063 |
+
;
|
| 1064 |
+
; 'CHGSGN' CHECKS SIGN N OF HL AND B UNCONDITIONALLY.
|
| 1065 |
+
;
|
| 1066 |
+
; 'CKHLDE' CHECKS SIGN OF HL AND DE. IF DIFFERENT, HL AND DE
|
| 1067 |
+
; ARE INTERCHANGED. IF SAME SIGN, NOT INTERCHANGED. EITHER
|
| 1068 |
+
; CASE, HL DE ARE THEN COMPARED TO SET THE FLAGS.
|
| 1069 |
+
;*************************************************************
|
| 1070 |
+
|
| 1071 |
+
DIVIDE:
|
| 1072 |
+
PUSH HL ;*** DIVIDE ***
|
| 1073 |
+
LD L,H ;DIVIDE H BY DE
|
| 1074 |
+
LD H,00H
|
| 1075 |
+
CALL DV1
|
| 1076 |
+
LD B,C ;SAVE RESULT IN B
|
| 1077 |
+
LD A,L ;(REMAINDER+L)/DE
|
| 1078 |
+
POP HL
|
| 1079 |
+
LD H,A
|
| 1080 |
+
DV1:
|
| 1081 |
+
LD C,0FFH ;RESULT IN C
|
| 1082 |
+
DV2:
|
| 1083 |
+
INC C ;DUMB ROUTINE
|
| 1084 |
+
CALL SUBDE ;DIVIDE BY SUBTRACT
|
| 1085 |
+
JR NC,DV2 ;AND COUNT
|
| 1086 |
+
ADD HL,DE
|
| 1087 |
+
RET
|
| 1088 |
+
SUBDE:
|
| 1089 |
+
LD A,L ;*** SUBDE ***
|
| 1090 |
+
SUB E ;SUBSTRACT DE FROM
|
| 1091 |
+
LD L,A ;HL
|
| 1092 |
+
LD A,H
|
| 1093 |
+
SBC A,D
|
| 1094 |
+
LD H,A
|
| 1095 |
+
RET
|
| 1096 |
+
CHKSGN:
|
| 1097 |
+
LD A,H ;*** CHKSGN ***
|
| 1098 |
+
OR A ;CHECK SIGN OF HL
|
| 1099 |
+
RET P
|
| 1100 |
+
CHGSGN:
|
| 1101 |
+
LD A,H ;*** CHGSGN ***
|
| 1102 |
+
PUSH AF
|
| 1103 |
+
CPL ;CHANGE SIGN OF HL
|
| 1104 |
+
LD H,A
|
| 1105 |
+
LD A,L
|
| 1106 |
+
CPL
|
| 1107 |
+
LD L,A
|
| 1108 |
+
INC HL
|
| 1109 |
+
POP AF
|
| 1110 |
+
XOR H
|
| 1111 |
+
JP P,QHOW
|
| 1112 |
+
LD A,B ;AND ALSO FLIP B
|
| 1113 |
+
XOR 80H
|
| 1114 |
+
LD B,A
|
| 1115 |
+
RET
|
| 1116 |
+
CKHLDE:
|
| 1117 |
+
LD A,H ;SAME SIGN?
|
| 1118 |
+
XOR D ;YES, COMPARE
|
| 1119 |
+
JP P,CK1 ;NO, XCHANGE AND COMP
|
| 1120 |
+
EX DE,HL
|
| 1121 |
+
CK1:
|
| 1122 |
+
RST 20H
|
| 1123 |
+
RET
|
| 1124 |
+
;*************************************************************
|
| 1125 |
+
;
|
| 1126 |
+
; *** SETVAL *** FIN *** ENDCHK *** & ERROR (& FRIENDS) ***
|
| 1127 |
+
;
|
| 1128 |
+
; "SETVAL" EXPECTS A VARIABLE, FOLLOWED BY AN EQUAL SIGN AND
|
| 1129 |
+
; THEN AN EXPR. IT EVALUATES THE EXPR. AND SET THE VARIABLE
|
| 1130 |
+
; TO THAT VALUE.
|
| 1131 |
+
;
|
| 1132 |
+
; "FIN" CHECKS THE END OF A COMMAND. IF IT ENDED WITH ";",
|
| 1133 |
+
; EXECUTION CONTINUES. IF IT ENDED WITH A CR, IT FINDS THE
|
| 1134 |
+
; NEXT LINE AND CONTINUE FROM THERE.
|
| 1135 |
+
;
|
| 1136 |
+
; "ENDCHK" CHECKS IF A COMMAND IS ENDED WITH CR. THIS IS
|
| 1137 |
+
; REQUIRED IN CERTAIN COMMANDS. (GOTO, RETURN, AND STOP ETC.)
|
| 1138 |
+
;
|
| 1139 |
+
; "ERROR" PRINTS THE STRING POINTED BY DE (AND ENDS WITH CR).
|
| 1140 |
+
; IT THEN PRINTS THE LINE POINTED BY 'CURRNT' WITH A "?"
|
| 1141 |
+
; INSERTED AT WHERE THE OLD TEXT POINTER (SHOULD BE ON TOP
|
| 1142 |
+
; OF THE STACK) POINTS TO. EXECUTION OF TB IS STOPPED
|
| 1143 |
+
; AND TBI IS RESTARTED. HOWEVER, IF 'CURRNT' -> ZERO
|
| 1144 |
+
; (INDICATING A DIRECT COMMAND), THE DIRECT COMMAND IS NOT
|
| 1145 |
+
; PRINTED. AND IF 'CURRNT' -> NEGATIVE # (INDICATING 'INPUT'
|
| 1146 |
+
; COMMAND), THE INPUT LINE IS NOT PRINTED AND EXECUTION IS
|
| 1147 |
+
; NOT TERMINATED BUT CONTINUED AT 'INPERR'.
|
| 1148 |
+
;
|
| 1149 |
+
; RELATED TO 'ERROR' ARE THE FOLLOWING:
|
| 1150 |
+
; 'QWHAT' SAVES TEXT POINTER IN STACK AND GET MESSAGE "WHAT?"
|
| 1151 |
+
; 'AWHAT' JUST GET MESSAGE "WHAT?" AND JUMP TO 'ERROR'.
|
| 1152 |
+
; 'QSORRY' AND 'ASORRY' DO SAME KIND OF THING.
|
| 1153 |
+
; 'AHOW' AND 'AHOW' IN THE ZERO PAGE SECTION ALSO DO THIS.
|
| 1154 |
+
;*************************************************************
|
| 1155 |
+
|
| 1156 |
+
SETVAL:
|
| 1157 |
+
RST 38H ;*** SETVAL ***
|
| 1158 |
+
JP C,QWHAT ;"WHAT?" NO VARIABLE
|
| 1159 |
+
PUSH HL ;SAVE ADDRESS OF VAR.
|
| 1160 |
+
RST 08H ;PASS "=" SIGN
|
| 1161 |
+
DB '='
|
| 1162 |
+
DB SV1-$-1
|
| 1163 |
+
RST 18H ;EVALUATE EXPR.
|
| 1164 |
+
LD B,H ;VALUE IS IN BC NOW
|
| 1165 |
+
LD C,L
|
| 1166 |
+
POP HL ;GET ADDRESS
|
| 1167 |
+
LD (HL),C ;SAVE VALUE
|
| 1168 |
+
INC HL
|
| 1169 |
+
LD (HL),B
|
| 1170 |
+
RET
|
| 1171 |
+
SV1:
|
| 1172 |
+
JP QWHAT ;NO "=" SIGN
|
| 1173 |
+
FIN:
|
| 1174 |
+
RST 08H ;*** FIN ***
|
| 1175 |
+
DB 3BH
|
| 1176 |
+
DB FI1-$-1
|
| 1177 |
+
POP AF ;";", PURGE RET. ADDR.
|
| 1178 |
+
JP RUNSML ;CONTINUE SAME LINE
|
| 1179 |
+
FI1:
|
| 1180 |
+
RST 08H ;NOT ";", IS IT CR?
|
| 1181 |
+
DB CR
|
| 1182 |
+
DB FI2-$-1
|
| 1183 |
+
POP AF ;YES, PURGE RET. ADDR.
|
| 1184 |
+
JP RUNNXL ;RUN NEXT LINE
|
| 1185 |
+
FI2:
|
| 1186 |
+
RET ;ELSE RETURN TO CALLER
|
| 1187 |
+
ENDCHK:
|
| 1188 |
+
RST 28H ;*** ENDCHK ***
|
| 1189 |
+
CP CR ;END WITH CR?
|
| 1190 |
+
RET Z ;OK, ELSE SAY: "WHAT?"
|
| 1191 |
+
QWHAT:
|
| 1192 |
+
PUSH DE ;*** QWHAT ***
|
| 1193 |
+
AWHAT:
|
| 1194 |
+
LD DE,WHAT ;*** AWHAT ***
|
| 1195 |
+
ERROR_ROUTINE:
|
| 1196 |
+
SUB A ;*** ERROR ***
|
| 1197 |
+
CALL PRTSTG ;PRINT 'WHAT?', 'HOW?'
|
| 1198 |
+
POP DE ;OR 'SORRY'
|
| 1199 |
+
LD A,(DE) ;SAVE THE CHARACTER
|
| 1200 |
+
PUSH AF ;AT WHERE OLD DE ->
|
| 1201 |
+
SUB A ;AND PUT A 0 THERE
|
| 1202 |
+
LD (DE),A
|
| 1203 |
+
LD HL,(CURRNT) ;GET CURRENT LINE #
|
| 1204 |
+
PUSH HL
|
| 1205 |
+
LD A,(HL) ;CHECK THE VALUE
|
| 1206 |
+
INC HL
|
| 1207 |
+
OR (HL)
|
| 1208 |
+
POP DE
|
| 1209 |
+
JP Z,RSTART ;IF ZERO, JUST RESTART
|
| 1210 |
+
LD A,(HL) ;IF NEGATIVE,
|
| 1211 |
+
OR A
|
| 1212 |
+
JP M,INPERR ;REDO INPUT
|
| 1213 |
+
CALL PRTLN ;ELSE PRINT THE LINE
|
| 1214 |
+
DEC DE ;UPTO WHERE THE 0 IS
|
| 1215 |
+
POP AF ;RESTORE THE CHARACTER
|
| 1216 |
+
LD (DE),A
|
| 1217 |
+
LD A,3FH ;PRINT A "?"
|
| 1218 |
+
RST 10H
|
| 1219 |
+
SUB A ;AND THE REST OF THE
|
| 1220 |
+
CALL PRTSTG ;LINE
|
| 1221 |
+
JP RSTART ;THEN RESTART
|
| 1222 |
+
QSORRY:
|
| 1223 |
+
PUSH DE ;*** QSORRY ***
|
| 1224 |
+
ASORRY:
|
| 1225 |
+
LD DE,SORRY ;*** ASORRY ***
|
| 1226 |
+
JR ERROR_ROUTINE
|
| 1227 |
+
;*************************************************************
|
| 1228 |
+
;
|
| 1229 |
+
; *** GETLN *** FNDLN (& FRIENDS) ***
|
| 1230 |
+
;
|
| 1231 |
+
; 'GETLN' READS A INPUT LINE INTO 'BUFFER'. IT FIRST PROMPT
|
| 1232 |
+
; THE CHARACTER IN A (GIVEN BY THE CALLER), THEN IT FILLS
|
| 1233 |
+
; THE BUFFER AND ECHOS. IT IGNORES LF'S AND NULLS, BUT STILL
|
| 1234 |
+
; ECHOS THEM BACK. RUB-OUT IS USED TO CAUSE IT TO DELETE
|
| 1235 |
+
; THE LAST CHARACTER (IF THERE IS ONE), AND ALT-MOD IS USED TO
|
| 1236 |
+
; CAUSE IT TO DELETE THE WHOLE LINE AND START IT ALL OVER.
|
| 1237 |
+
; CR SIGNALS THE END OF A LINE, AND CAUSE 'GETLN' TO RETURN.
|
| 1238 |
+
;
|
| 1239 |
+
; 'FNDLN' FINDS A LINE WITH A GIVEN LINE # (IN HL) IN THE
|
| 1240 |
+
; TEXT SAVE AREA. DE IS USED AS THE TEXT POINTER. IF THE
|
| 1241 |
+
; LINE IS FOUND, DE WILL POINT TO THE BEGINNING OF THAT LINE
|
| 1242 |
+
; (I.E., THE LOW BYTE OF THE LINE #), AND FLAGS ARE NC & Z.
|
| 1243 |
+
; IF THAT LINE IS NOT THERE AND A LINE WITH A HIGHER LINE #
|
| 1244 |
+
; IS FOUND, DE POINTS TO THERE AND FLAGS ARE NC & NZ. IF
|
| 1245 |
+
; WE REACHED THE END OF TEXT SAVE AREA AND CANNOT FIND THE
|
| 1246 |
+
; LINE, FLAGS ARE C & NZ.
|
| 1247 |
+
; 'FNDLN' WILL INITIALIZE DE TO THE BEGINNING OF THE TEXT SAVE
|
| 1248 |
+
; AREA TO START THE SEARCH. SOME OTHER ENTRIES OF THIS
|
| 1249 |
+
; ROUTINE WILL NOT INITIALIZE DE AND DO THE SEARCH.
|
| 1250 |
+
; 'FNDLNP' WILL START WITH DE AND SEARCH FOR THE LINE #.
|
| 1251 |
+
; 'FNDNXT' WILL BUMP DE BY 2, FIND A CR AND THEN START SEARCH.
|
| 1252 |
+
; 'FNDSKP' USE DE TO FIND A CR, AND THEN START SEARCH.
|
| 1253 |
+
;*************************************************************
|
| 1254 |
+
|
| 1255 |
+
GETLN:
|
| 1256 |
+
RST 10H ;*** GETLN ***
|
| 1257 |
+
LD DE,BUFFER ;PROMPT AND INIT.
|
| 1258 |
+
GL1:
|
| 1259 |
+
CALL CHKIO ;CHECK KEYBOARD
|
| 1260 |
+
JR Z,GL1 ;NO INPUT, WAIT
|
| 1261 |
+
CP 7FH ;DELETE LAST CHARACTER?
|
| 1262 |
+
JR Z,GL3 ;YES
|
| 1263 |
+
RST 10H ;INPUT, ECHO BACK
|
| 1264 |
+
CP 0AH ;IGNORE LF
|
| 1265 |
+
JR Z,GL1
|
| 1266 |
+
OR A ;IGNORE NULL
|
| 1267 |
+
JR Z,GL1
|
| 1268 |
+
CP 7DH ;DELETE THE WHOLE LINE?
|
| 1269 |
+
JR Z,GL4 ;YES
|
| 1270 |
+
LD (DE),A ;ELSE SAVE INPUT
|
| 1271 |
+
INC DE ;AND BUMP POINTER
|
| 1272 |
+
CP 0DH ;WAS IT CR
|
| 1273 |
+
RET Z ;YES, END OF LINE
|
| 1274 |
+
LD A,E ;ELSE MORE FREE ROOM?
|
| 1275 |
+
CP BUFEND & 0FFH
|
| 1276 |
+
JR NZ,GL1 ;YES, GET NEXT INPUT
|
| 1277 |
+
GL3:
|
| 1278 |
+
LD A,E ;DELETE LAST CHARACTER
|
| 1279 |
+
CP BUFFER & 0FFH ;BUT DO WE HAVE ANY?
|
| 1280 |
+
JR Z,GL4 ;NO, REDO WHOLE LINE
|
| 1281 |
+
DEC DE ;YES, BACKUP POINTER
|
| 1282 |
+
LD A,5CH ;AND ECHO A BACK-SLASH
|
| 1283 |
+
RST 10H
|
| 1284 |
+
JR GL1 ;GO GET NEXT INPUT
|
| 1285 |
+
GL4:
|
| 1286 |
+
CALL CRLF ;REDO ENTIRE LINE
|
| 1287 |
+
LD A,05EH ;CR, LF AND UP-ARROW
|
| 1288 |
+
JR GETLN
|
| 1289 |
+
FNDLN:
|
| 1290 |
+
LD A,H ;*** FNDLN ***
|
| 1291 |
+
OR A ;CHECK SIGN OF HL
|
| 1292 |
+
JP M,QHOW ;IT CANNOT BE -
|
| 1293 |
+
LD DE,TXTBGN ;INIT TEXT POINTER
|
| 1294 |
+
FNDLP: ;*** FDLNP ***
|
| 1295 |
+
FL1:
|
| 1296 |
+
PUSH HL ;SAVE LINE #
|
| 1297 |
+
LD HL,(TXTUNF) ;CHECK IF WE PASSED END
|
| 1298 |
+
DEC HL
|
| 1299 |
+
RST 20H
|
| 1300 |
+
POP HL ;GET LINE # BACK
|
| 1301 |
+
RET C ;C,NZ PASSED END
|
| 1302 |
+
LD A,(DE) ;WE DID NOT, GET BYTE 1
|
| 1303 |
+
SUB L ;IS THIS THE LINE?
|
| 1304 |
+
LD B,A ;COMPARE LOW ORDER
|
| 1305 |
+
INC DE
|
| 1306 |
+
LD A,(DE) ;GET BYTE 2
|
| 1307 |
+
SBC A,H ;COMPARE HIGH ORDER
|
| 1308 |
+
JR C,FL2 ;NO, NOT THERE YET
|
| 1309 |
+
DEC DE ;ELSE WE EITHER FOUND
|
| 1310 |
+
OR B ;IT, OR IT IS NOT THERE
|
| 1311 |
+
RET ;NC,Z;FOUND, NC,NZ:NO
|
| 1312 |
+
FNDNXT: ;*** FNDNXT ***
|
| 1313 |
+
INC DE ;FIND NEXT LINE
|
| 1314 |
+
FL2:
|
| 1315 |
+
INC DE ;JUST PASSED BYTE 1 & 2
|
| 1316 |
+
FNDSKP:
|
| 1317 |
+
LD A,(DE) ;*** FNDSKP ***
|
| 1318 |
+
CP CR ;TRY TO FIND CR
|
| 1319 |
+
JR NZ,FL2 ;KEEP LOOKING
|
| 1320 |
+
INC DE ;FOUND CR, SKIP OVER
|
| 1321 |
+
JR FL1 ;CHECK IF END OF TEXT
|
| 1322 |
+
;*************************************************************
|
| 1323 |
+
;
|
| 1324 |
+
; *** PRTSTG *** QTSTG *** PRTNUM *** & PRTLN ***
|
| 1325 |
+
;
|
| 1326 |
+
; 'PRTSTG' PRINTS A STRING POINTED BY DE. IT STOPS PRINTING
|
| 1327 |
+
; AND RETURNS TO CALLER WHEN EITHER A CR IS PRINTED OR WHEN
|
| 1328 |
+
; THE NEXT BYTE IS THE SAME AS WHAT WAS IN A (GIVEN BY THE
|
| 1329 |
+
; CALLER). OLD A IS STORED IN B, OLD B IS LOST.
|
| 1330 |
+
;
|
| 1331 |
+
; 'QTSTG' LOOKS FOR A BACK-ARROW, SINGLE QUOTE, OR DOUBLE
|
| 1332 |
+
; QUOTE. IF NONE OF THESE, RETURN TO CALLER. IF BACK-ARROW,
|
| 1333 |
+
; OUTPUT A CR WITHOUT A LF. IF SINGLE OR DOUBLE QUOTE, PRINT
|
| 1334 |
+
; THE STRING IN THE QUOTE AND DEMANDS A MATCHING UNQUOTE.
|
| 1335 |
+
; AFTER THE PRINTING THE NEXT 3 BYTES OF THE CALLER IS SKIPPED
|
| 1336 |
+
; OVER (USUALLY A JUMP INSTRUCTION.
|
| 1337 |
+
;
|
| 1338 |
+
; 'PRTNUM' PRINTS THE NUMBER IN HL. LEADING BLANKS ARE ADDED
|
| 1339 |
+
; IF NEEDED TO PAD THE NUMBER OF SPACES TO THE NUMBER IN C.
|
| 1340 |
+
; HOWEVER, IF THE NUMBER OF DIGITS IS LARGER THAN THE # IN
|
| 1341 |
+
; C, ALL DIGITS ARE PRINTED ANYWAY. NEGATIVE SIGN IS ALSO
|
| 1342 |
+
; PRINTED AND COUNTED IN, POSITIVE SIGN IS NOT.
|
| 1343 |
+
;
|
| 1344 |
+
; 'PRTLN' PRINTS A SAVED TEXT LINE WITH LINE # AND ALL.
|
| 1345 |
+
;*************************************************************
|
| 1346 |
+
|
| 1347 |
+
PRTSTG:
|
| 1348 |
+
LD B,A ;*** PRTSTG ***
|
| 1349 |
+
PS1:
|
| 1350 |
+
LD A,(DE) ;GET A CHARACTER
|
| 1351 |
+
INC DE ;BUMP POINTER
|
| 1352 |
+
CP B ;SAME AS OLD A?
|
| 1353 |
+
RET Z ;YES, RETURN
|
| 1354 |
+
RST 10H ;NO, NEXT
|
| 1355 |
+
CP CR ;WAS IT A CR?
|
| 1356 |
+
JR NZ,PS1 ;NO, NEXT
|
| 1357 |
+
RET ;YES, RETURN
|
| 1358 |
+
QTSTG:
|
| 1359 |
+
RST 08H ;*** QTSTG ***
|
| 1360 |
+
DB '"'
|
| 1361 |
+
DB QT3-$-1
|
| 1362 |
+
LD A,22H ;IT IS A "
|
| 1363 |
+
QT1:
|
| 1364 |
+
CALL PRTSTG ;PRINT UNTIL ANOTHER
|
| 1365 |
+
CP CR ;WAS LAST ONE A CR?
|
| 1366 |
+
POP HL ;RETURN ADDRESS
|
| 1367 |
+
JP Z,RUNNXL ;WAS CR, RUN NEXT LINE
|
| 1368 |
+
QT2:
|
| 1369 |
+
INC HL ;SKIP 3 BYTES ON RETURN
|
| 1370 |
+
INC HL
|
| 1371 |
+
INC HL
|
| 1372 |
+
JP (HL) ;RETURN
|
| 1373 |
+
QT3:
|
| 1374 |
+
RST 08H ;IS IT A '?
|
| 1375 |
+
DB 27H
|
| 1376 |
+
DB QT4-$-1
|
| 1377 |
+
LD A,27H ;YES, DO THE SAME
|
| 1378 |
+
JR QT1 ;AS IN "
|
| 1379 |
+
QT4:
|
| 1380 |
+
RST 08H ;IS IT BACK-ARROW?
|
| 1381 |
+
DB 5FH
|
| 1382 |
+
DB QT5-$-1
|
| 1383 |
+
LD A,8DH ;YES, CR WITHOUT LF
|
| 1384 |
+
RST 10H ;DO IT TWICE TO GIVE
|
| 1385 |
+
RST 10H ;TTY ENOUGH TIME
|
| 1386 |
+
POP HL ;RETURN ADDRESS
|
| 1387 |
+
JR QT2
|
| 1388 |
+
QT5:
|
| 1389 |
+
RET ;NONE OF ABOVE
|
| 1390 |
+
;
|
| 1391 |
+
PRTNUM:
|
| 1392 |
+
LD B,00H ;*** PRTNUM ***
|
| 1393 |
+
CALL CHKSGN ;CHECK SIGN
|
| 1394 |
+
JP P,PN1 ;NO SIGN
|
| 1395 |
+
LD B,'-' ;B=SIGN
|
| 1396 |
+
DEC C ;'-' TAKES SPACE
|
| 1397 |
+
PN1:
|
| 1398 |
+
PUSH DE ;SAVE
|
| 1399 |
+
LD DE,000AH ;DECIMAL
|
| 1400 |
+
PUSH DE ;SAVE AS FLAG
|
| 1401 |
+
DEC C ;C=SPACES
|
| 1402 |
+
PUSH BC ;SAVE SIGN & SPACE
|
| 1403 |
+
PN2:
|
| 1404 |
+
CALL DIVIDE ;DIVIDE HL BY 10
|
| 1405 |
+
LD A,B ;RESULT 0?
|
| 1406 |
+
OR C
|
| 1407 |
+
JR Z,PN3 ;YES, WE GOT ALL
|
| 1408 |
+
EX (SP),HL ;NO, SAVE REMAINDER
|
| 1409 |
+
DEC L ;AND COUNT SPACE
|
| 1410 |
+
PUSH HL ;HL IS OLD BC
|
| 1411 |
+
LD H,B ;MOVE RESULT TO BC
|
| 1412 |
+
LD L,C
|
| 1413 |
+
JR PN2 ;AND DIVIDE BY 10
|
| 1414 |
+
PN3:
|
| 1415 |
+
POP BC ;WE GOT ALL DIGITS IN
|
| 1416 |
+
PN4:
|
| 1417 |
+
DEC C ;THE STACK
|
| 1418 |
+
LD A,C ;LOOK AT SPACE COUNT
|
| 1419 |
+
OR A
|
| 1420 |
+
JP M,PN5 ;NO LEADING BLANKS
|
| 1421 |
+
LD A,20H ;LEADING BLANKS
|
| 1422 |
+
RST 10H
|
| 1423 |
+
JR PN4 ;MORE?
|
| 1424 |
+
PN5:
|
| 1425 |
+
LD A,B ;PRINT SIGN
|
| 1426 |
+
OR A
|
| 1427 |
+
CALL NZ,0010H
|
| 1428 |
+
LD E,L ;LAST REMAINDER IN E
|
| 1429 |
+
PN6:
|
| 1430 |
+
LD A,E ;CHECK DIGIT IN E
|
| 1431 |
+
CP 0AH ;10 IS FLAG FOR NO MORE
|
| 1432 |
+
POP DE
|
| 1433 |
+
RET Z ;IF SO, RETURN
|
| 1434 |
+
ADD A,30H ;ELSE, CONVERT TO ASCII
|
| 1435 |
+
RST 10H ;PRINT THE DIGIT
|
| 1436 |
+
JR PN6 ;GO BACK FOR MORE
|
| 1437 |
+
PRTLN:
|
| 1438 |
+
LD A,(DE) ;*** PRTLN ***
|
| 1439 |
+
LD L,A ;LOW ORDER LINE #
|
| 1440 |
+
INC DE
|
| 1441 |
+
LD A,(DE) ;HIGH ORDER
|
| 1442 |
+
LD H,A
|
| 1443 |
+
INC DE
|
| 1444 |
+
LD C,04H ;PRINT 4 DIGIT LINE #
|
| 1445 |
+
CALL PRTNUM
|
| 1446 |
+
LD A,20H ;FOLLOWED BY A BLANK
|
| 1447 |
+
RST 10H
|
| 1448 |
+
SUB A ;AND THEN THE NEXT
|
| 1449 |
+
CALL PRTSTG
|
| 1450 |
+
RET
|
| 1451 |
+
;*************************************************************
|
| 1452 |
+
;
|
| 1453 |
+
; *** MVUP *** MVDOWN *** POPA *** & PUSHA ***
|
| 1454 |
+
;
|
| 1455 |
+
; 'MVUP' MOVES A BLOCK UP FROM WHERE DE-> TO WHERE BC-> UNTIL
|
| 1456 |
+
; DE = HL
|
| 1457 |
+
;
|
| 1458 |
+
; 'MVDOWN' MOVES A BLOCK DOWN FROM WHERE DE-> TO WHERE HL->
|
| 1459 |
+
; UNTIL DE = BC
|
| 1460 |
+
;
|
| 1461 |
+
; 'POPA' RESTORES THE 'FOR' LOOP VARIABLE SAVE AREA FROM THE
|
| 1462 |
+
; STACK
|
| 1463 |
+
;
|
| 1464 |
+
; 'PUSHA' STACKS THE 'FOR' LOOP VARIABLE SAVE AREA INTO THE
|
| 1465 |
+
; STACK
|
| 1466 |
+
;*************************************************************
|
| 1467 |
+
|
| 1468 |
+
MVUP:
|
| 1469 |
+
RST 20H ;*** MVUP ***
|
| 1470 |
+
RET Z ;DE = HL, RETURN
|
| 1471 |
+
LD A,(DE) ;GET ONE BYTE
|
| 1472 |
+
LD (BC),A ;MOVE IT
|
| 1473 |
+
INC DE ;INCREASE BOTH POINTERS
|
| 1474 |
+
INC BC
|
| 1475 |
+
JR MVUP ;UNTIL DONE
|
| 1476 |
+
MVDOWN:
|
| 1477 |
+
LD A,B ;*** MVDOWN ***
|
| 1478 |
+
SUB D ;TEST IF DE = BC
|
| 1479 |
+
JP NZ,MD1 ;NO, GO MOVE
|
| 1480 |
+
LD A,C ;MAYBE, OTHER BYTE?
|
| 1481 |
+
SUB E
|
| 1482 |
+
RET Z ;YES, RETURN
|
| 1483 |
+
MD1:
|
| 1484 |
+
DEC DE ;ELSE MOVE A BYTE
|
| 1485 |
+
DEC HL ;BUT FIRST DECREASE
|
| 1486 |
+
LD A,(DE) ;BOTH POINTERS AND
|
| 1487 |
+
LD (HL),A ;THEN DO IT
|
| 1488 |
+
JR MVDOWN ;LOOP BACK
|
| 1489 |
+
POPA:
|
| 1490 |
+
POP BC ;BC = RETURN ADDR.
|
| 1491 |
+
POP HL ;RESTORE LOPVAR, BUT
|
| 1492 |
+
LD (LOPVAR),HL ;=0 MEANS NO MORE
|
| 1493 |
+
LD A,H
|
| 1494 |
+
OR L
|
| 1495 |
+
JR Z,PP1 ;YEP, GO RETURN
|
| 1496 |
+
POP HL ;NOP, RESTORE OTHERS
|
| 1497 |
+
LD (LOPINC),HL
|
| 1498 |
+
POP HL
|
| 1499 |
+
LD (LOPLMT),HL
|
| 1500 |
+
POP HL
|
| 1501 |
+
LD (LOPLN),HL
|
| 1502 |
+
POP HL
|
| 1503 |
+
LD (LOPPT),HL
|
| 1504 |
+
PP1:
|
| 1505 |
+
PUSH BC ;BC = RETURN ADDR.
|
| 1506 |
+
RET
|
| 1507 |
+
PUSHA:
|
| 1508 |
+
LD HL,STKLMT ;*** PUSHA ***
|
| 1509 |
+
CALL CHGSGN
|
| 1510 |
+
POP BC ;BC=RETURN ADDRESS
|
| 1511 |
+
ADD HL,SP ;IS STACK NEAR THE TOP?
|
| 1512 |
+
JP NC,QSORRY ;YES, SORRY FOR THAT
|
| 1513 |
+
LD HL,(LOPVAR) ;ELSE SAVE LOOP VAR'S
|
| 1514 |
+
LD A,H ;BUT IF LOPVAR IS 0
|
| 1515 |
+
OR L ;THAT WILL BE ALL
|
| 1516 |
+
JR Z,PU1
|
| 1517 |
+
LD HL,(LOPPT) ;ELSE, MORE TO SAVE
|
| 1518 |
+
PUSH HL
|
| 1519 |
+
LD HL,(LOPLN)
|
| 1520 |
+
PUSH HL
|
| 1521 |
+
LD HL,(LOPLMT)
|
| 1522 |
+
PUSH HL
|
| 1523 |
+
LD HL,(LOPINC)
|
| 1524 |
+
PUSH HL
|
| 1525 |
+
LD HL,(LOPVAR)
|
| 1526 |
+
PU1:
|
| 1527 |
+
PUSH HL
|
| 1528 |
+
PUSH BC ;BC = RETURN ADDR.
|
| 1529 |
+
RET
|
| 1530 |
+
;*************************************************************
|
| 1531 |
+
;
|
| 1532 |
+
; *** OUTC *** & CHKIO ***
|
| 1533 |
+
;
|
| 1534 |
+
; THESE ARE THE ONLY I/O ROUTINES IN TBI.
|
| 1535 |
+
; 'OUTC' IS CONTROLLED BY A SOFTWARE SWITCH 'OCSW'. IF OCSW=0
|
| 1536 |
+
; 'OUTC' WILL JUST RETURN TO THE CALLER. IF OCSW IS NOT 0,
|
| 1537 |
+
; IT WILL OUTPUT THE BYTE IN A. IF THAT IS A CR, A LF IS ALSO
|
| 1538 |
+
; SEND OUT. ONLY THE FLAGS MAY BE CHANGED AT RETURN. ALL REG.
|
| 1539 |
+
; ARE RESTORED.
|
| 1540 |
+
;
|
| 1541 |
+
; 'CHKIO' CHECKS THE INPUT. IF NO INPUT, IT WILL RETURN TO
|
| 1542 |
+
; THE CALLER WITH THE Z FLAG SET. IF THERE IS INPUT, Z FLAG
|
| 1543 |
+
; IS CLEARED AND THE INPUT BYTE IS IN A. HOWEVER, IF THE
|
| 1544 |
+
; INPUT IS A CONTROL-O, THE 'OCSW' SWITCH IS COMPLIMENTED, AND
|
| 1545 |
+
; Z FLAG IS RETURNED. IF A CONTROL-C IS READ, 'CHKIO' WILL
|
| 1546 |
+
; RESTART TBI AND DO NOT RETURN TO THE CALLER.
|
| 1547 |
+
;
|
| 1548 |
+
; Do not modify these routines. Routines requiring
|
| 1549 |
+
; modification are : SERIAL_INIT, RX_RDY, and TX_RDY.
|
| 1550 |
+
;*************************************************************
|
| 1551 |
+
|
| 1552 |
+
INIT:
|
| 1553 |
+
CALL SERIAL_INIT ;INITIALIZE THE SIO
|
| 1554 |
+
LD D,19H
|
| 1555 |
+
PATLOP:
|
| 1556 |
+
CALL CRLF
|
| 1557 |
+
DEC D
|
| 1558 |
+
JR NZ,PATLOP
|
| 1559 |
+
SUB A
|
| 1560 |
+
LD DE,MSG1 ;PRINT THE BOOT MESSAGES
|
| 1561 |
+
CALL PRTSTG
|
| 1562 |
+
LD DE,MSG2
|
| 1563 |
+
CALL PRTSTG
|
| 1564 |
+
LD HL,START
|
| 1565 |
+
LD (RANPNT),HL
|
| 1566 |
+
LD HL,TXTBGN
|
| 1567 |
+
LD (TXTUNF),HL
|
| 1568 |
+
JP RSTART
|
| 1569 |
+
OUTC:
|
| 1570 |
+
JR NZ,OUTC2 ;IT IS ON
|
| 1571 |
+
POP AF ;IT IS OFF
|
| 1572 |
+
RET ;RESTORE AF AND RETURN
|
| 1573 |
+
OUTC2:
|
| 1574 |
+
CALL TX_RDY ;SEE IF TRANSMIT IS AVAILABLE
|
| 1575 |
+
POP AF ;RESTORE THE REGISTER
|
| 1576 |
+
OUT (SerialPort),A ;SEND THE BYTE
|
| 1577 |
+
CP CR
|
| 1578 |
+
RET NZ
|
| 1579 |
+
LD A,LF
|
| 1580 |
+
RST 10H
|
| 1581 |
+
LD A,CR
|
| 1582 |
+
RET
|
| 1583 |
+
CHKIO:
|
| 1584 |
+
CALL RX_RDY ;CHECK IF CHARACTER AVAILABLE
|
| 1585 |
+
RET Z ;RETURN IF NO CHARACTER AVAILABLE
|
| 1586 |
+
|
| 1587 |
+
PUSH BC ;IF IT'S A LF, IGNORE AND RETURN
|
| 1588 |
+
LD B,A ; AS IF THERE WAS NO CHARACTER.
|
| 1589 |
+
SUB LF
|
| 1590 |
+
JR Z,CHKIO2
|
| 1591 |
+
LD A,B ;OTHERWISE RESTORE 'A' AND 'BC'
|
| 1592 |
+
POP BC ; AND CONTINUE ON.
|
| 1593 |
+
|
| 1594 |
+
CP 0FH ;IS IT CONTROL-0?
|
| 1595 |
+
JR NZ,CI1 ;NO, MORE CHECKING
|
| 1596 |
+
LD A,(OCSW) ;CONTROL-0 FLIPS OCSW
|
| 1597 |
+
CPL ;ON TO OFF, OFF TO ON
|
| 1598 |
+
LD (OCSW),A
|
| 1599 |
+
JR CHKIO ;GET ANOTHER INPUT
|
| 1600 |
+
CHKIO2:
|
| 1601 |
+
LD A,00H ;CLEAR A
|
| 1602 |
+
OR A ;ZET THE Z-FLAG
|
| 1603 |
+
POP BC ;RESTORE THE 'BC' PAIR
|
| 1604 |
+
RET ;RETURN WITH 'Z' SET.
|
| 1605 |
+
CI1:
|
| 1606 |
+
CP 03H ;IS IT CONTROL-C?
|
| 1607 |
+
RET NZ ;NO, RETURN "NZ"
|
| 1608 |
+
JP RSTART ;YES, RESTART TBI
|
| 1609 |
+
|
| 1610 |
+
|
| 1611 |
+
MSG1: DB ESC,"[2J",ESC,"[H" ;SCREEN CLEAR
|
| 1612 |
+
DB 'Z80 TINY BASIC 2.0g',CR ;BOOT MESSAGE
|
| 1613 |
+
MSG2: DB 'PORTED BY DOUG GABBARD, 2017',CR
|
| 1614 |
+
|
| 1615 |
+
;*************************************************************
|
| 1616 |
+
;
|
| 1617 |
+
; *** TABLES *** DIRECT *** & EXEC ***
|
| 1618 |
+
;
|
| 1619 |
+
; THIS SECTION OF THE CODE TESTS A STRING AGAINST A TABLE.
|
| 1620 |
+
; WHEN A MATCH IS FOUND, CONTROL IS TRANSFERED TO THE SECTION
|
| 1621 |
+
; OF CODE ACCORDING TO THE TABLE.
|
| 1622 |
+
;
|
| 1623 |
+
; AT 'EXEC', DE SHOULD POINT TO THE STRING AND HL SHOULD POINT
|
| 1624 |
+
; TO THE TABLE-1. AT 'DIRECT', DE SHOULD POINT TO THE STRING.
|
| 1625 |
+
; HL WILL BE SET UP TO POINT TO TAB1-1, WHICH IS THE TABLE OF
|
| 1626 |
+
; ALL DIRECT AND STATEMENT COMMANDS.
|
| 1627 |
+
;
|
| 1628 |
+
; A '.' IN THE STRING WILL TERMINATE THE TEST AND THE PARTIAL
|
| 1629 |
+
; MATCH WILL BE CONSIDERED AS A MATCH. E.G., 'P.', 'PR.',
|
| 1630 |
+
; 'PRI.', 'PRIN.', OR 'PRINT' WILL ALL MATCH 'PRINT'.
|
| 1631 |
+
;
|
| 1632 |
+
; THE TABLE CONSISTS OF ANY NUMBER OF ITEMS. EACH ITEM
|
| 1633 |
+
; IS A STRING OF CHARACTERS WITH BIT 7 SET TO 0 AND
|
| 1634 |
+
; A JUMP ADDRESS STORED HI-LOW WITH BIT 7 OF THE HIGH
|
| 1635 |
+
; BYTE SET TO 1.
|
| 1636 |
+
;
|
| 1637 |
+
; END OF TABLE IS AN ITEM WITH A JUMP ADDRESS ONLY. IF THE
|
| 1638 |
+
; STRING DOES NOT MATCH ANY OF THE OTHER ITEMS, IT WILL
|
| 1639 |
+
; MATCH THIS NULL ITEM AS DEFAULT.
|
| 1640 |
+
;*************************************************************
|
| 1641 |
+
|
| 1642 |
+
TAB1: ;DIRECT COMMANDS
|
| 1643 |
+
DB 'LIST'
|
| 1644 |
+
DWA LIST
|
| 1645 |
+
DB 'RUN'
|
| 1646 |
+
DWA RUN
|
| 1647 |
+
DB 'NEW'
|
| 1648 |
+
DWA NEW
|
| 1649 |
+
TAB2: ;DIRECT/STATEMENT
|
| 1650 |
+
DB 'NEXT'
|
| 1651 |
+
DWA NEXT
|
| 1652 |
+
DB 'LET'
|
| 1653 |
+
DWA LET
|
| 1654 |
+
DB 'IF'
|
| 1655 |
+
DWA IFF
|
| 1656 |
+
DB 'GOTO'
|
| 1657 |
+
DWA GOTO
|
| 1658 |
+
DB 'GOSUB'
|
| 1659 |
+
DWA GOSUB
|
| 1660 |
+
DB 'RETURN'
|
| 1661 |
+
DWA RETURN
|
| 1662 |
+
DB 'REM'
|
| 1663 |
+
DWA REM
|
| 1664 |
+
DB 'FOR'
|
| 1665 |
+
DWA FOR
|
| 1666 |
+
DB 'INPUT'
|
| 1667 |
+
DWA INPUT
|
| 1668 |
+
DB 'PRINT'
|
| 1669 |
+
DWA PRINT
|
| 1670 |
+
DB 'STOP'
|
| 1671 |
+
DWA STOP
|
| 1672 |
+
DWA DEFLT
|
| 1673 |
+
TAB4: ;FUNCTIONS
|
| 1674 |
+
DB 'RND'
|
| 1675 |
+
DWA RND
|
| 1676 |
+
DB 'ABS'
|
| 1677 |
+
DWA ABS
|
| 1678 |
+
DB 'SIZE'
|
| 1679 |
+
DWA SIZE
|
| 1680 |
+
DWA XP40
|
| 1681 |
+
TAB5: ;"TO" IN "FOR"
|
| 1682 |
+
DB 'TO'
|
| 1683 |
+
DWA FR1
|
| 1684 |
+
DWA QWHAT
|
| 1685 |
+
TAB6: ;"STEP" IN "FOR"
|
| 1686 |
+
DB 'STEP'
|
| 1687 |
+
DWA FR2
|
| 1688 |
+
DWA FR3
|
| 1689 |
+
TAB8: ;RELATION OPERATORS
|
| 1690 |
+
DB '>='
|
| 1691 |
+
DWA XP11
|
| 1692 |
+
DB '#'
|
| 1693 |
+
DWA XP12
|
| 1694 |
+
DB '>'
|
| 1695 |
+
DWA XP13
|
| 1696 |
+
DB '='
|
| 1697 |
+
DWA XP15
|
| 1698 |
+
DB '<='
|
| 1699 |
+
DWA XP14
|
| 1700 |
+
DB '<'
|
| 1701 |
+
DWA XP16
|
| 1702 |
+
DWA XP17
|
| 1703 |
+
DIRECT: LD HL,TAB1-1 ;*** DIRECT ***
|
| 1704 |
+
EXEC: ;*** EXEC ***
|
| 1705 |
+
EX0: RST 28H ;IGNORE LEADING BLANKS
|
| 1706 |
+
PUSH DE ;SAVE POINTER
|
| 1707 |
+
EX1:
|
| 1708 |
+
LD A,(DE) ;IF FOUND '.' IN STRING
|
| 1709 |
+
INC DE ;BEFORE ANY MISMATCH
|
| 1710 |
+
CP 23H ;WE DECLARE A MATCH
|
| 1711 |
+
JR Z,EX3
|
| 1712 |
+
INC HL ;HL->TABLE
|
| 1713 |
+
CP (HL) ;IF MATCH, TEST NEXT
|
| 1714 |
+
JR Z,EX1
|
| 1715 |
+
LD A,7FH ;ELSE SEE IF BIT 7
|
| 1716 |
+
DEC DE ;OF TABLE IS SET, WHICH
|
| 1717 |
+
CP (HL) ;IS THE JUMP ADDR. (HI)
|
| 1718 |
+
JR C,EX5 ;C:YES, MATCHED
|
| 1719 |
+
EX2:
|
| 1720 |
+
INC HL ;NC:NO, FIND JUMP ADDR.
|
| 1721 |
+
CP (HL)
|
| 1722 |
+
JR NC,EX2
|
| 1723 |
+
INC HL ;BUMP TO NEXT TAB. ITEM
|
| 1724 |
+
POP DE ;RESTORE STRING POINTER
|
| 1725 |
+
JR EX0 ;TEST AGAINST NEXT ITEM
|
| 1726 |
+
EX3:
|
| 1727 |
+
LD A,7FH ;PARTIAL MATCH, FIND
|
| 1728 |
+
EX4:
|
| 1729 |
+
INC HL ;JUMP ADDR., WHICH IS
|
| 1730 |
+
CP (HL) ;FLAGGED BY BIT 7
|
| 1731 |
+
JR NC,EX4
|
| 1732 |
+
EX5:
|
| 1733 |
+
LD A,(HL) ;LOAD HL WITH THE JUMP
|
| 1734 |
+
INC HL ;ADDRESS FROM THE TABLE
|
| 1735 |
+
LD L,(HL)
|
| 1736 |
+
AND 7FH ;MASK OFF BIT 7
|
| 1737 |
+
LD H,A
|
| 1738 |
+
POP AF ;CLEAN UP THE GABAGE
|
| 1739 |
+
JP (HL) ;AND WE GO DO IT
|
| 1740 |
+
;-------------------------------------------------------------------------------
|
| 1741 |
+
;///////////////////////////////////////////////////////////////////////////////
|
| 1742 |
+
;-------------------------------------------------------------------------------
|
| 1743 |
+
;COMPUTER SPECIFIC ROUTINES.
|
| 1744 |
+
;-------------------------------------------------------------------------------
|
| 1745 |
+
SERIAL_INIT:
|
| 1746 |
+
|
| 1747 |
+
; This routine is for initializing your serial port.
|
| 1748 |
+
|
| 1749 |
+
RET
|
| 1750 |
+
;-------------------------------------------------------------------------------
|
| 1751 |
+
TX_RDY:
|
| 1752 |
+
|
| 1753 |
+
; This routine is checking if the Serial Port is ready to send
|
| 1754 |
+
; a character.
|
| 1755 |
+
|
| 1756 |
+
RET
|
| 1757 |
+
|
| 1758 |
+
;-------------------------------------------------------------------------------
|
| 1759 |
+
RX_RDY:
|
| 1760 |
+
|
| 1761 |
+
; This routine is for checkif if a character is available over
|
| 1762 |
+
; serial. If a character is available, it returns to the calling
|
| 1763 |
+
; function with the character in 'A' and the Z-flag reset.
|
| 1764 |
+
; However, if a character is not available, it returns with the
|
| 1765 |
+
; Z-flag set.
|
| 1766 |
+
|
| 1767 |
+
RET
|
| 1768 |
+
;-------------------------------------------------------------------------------
|
| 1769 |
+
;///////////////////////////////////////////////////////////////////////////////
|
| 1770 |
+
;-------------------------------------------------------------------------------
|
| 1771 |
+
|
| 1772 |
+
LSTROM: ;ALL ABOVE CAN BE ROM
|
| 1773 |
+
;HERE DOWN MUST BE RAM
|
| 1774 |
+
ORG 08000H
|
| 1775 |
+
ORG 0FF00H
|
| 1776 |
+
VARBGN: DS 55 ;VARIABLE @(0)
|
| 1777 |
+
BUFFER: DS 64 ;INPUT BUFFER
|
| 1778 |
+
BUFEND: DS 1 ;BUFFER ENDS
|
| 1779 |
+
STKLMT: DS 1 ;TOP LIMIT FOR STACK
|
| 1780 |
+
END
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/asm/z80/jtTinyBasic.asm
ADDED
|
@@ -0,0 +1,1789 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
;*************************************************************
|
| 2 |
+
;
|
| 3 |
+
; TINY BASIC FOR ZILOG Z80
|
| 4 |
+
; VERSION 2.0
|
| 5 |
+
; BY LI-CHEN WANG
|
| 6 |
+
;
|
| 7 |
+
; MODIFIED AND TRANSLATED
|
| 8 |
+
; TO INTEL MNEMONICS
|
| 9 |
+
; BY ROGER RAUSKOLB
|
| 10 |
+
; 10 OCTOBER,1976
|
| 11 |
+
;
|
| 12 |
+
; MODIFIED AND TRANSLATED
|
| 13 |
+
; TO ZILOG MNEMONICS
|
| 14 |
+
; BY DOUG GABBARD
|
| 15 |
+
; www.retrodepot.net
|
| 16 |
+
;
|
| 17 |
+
; RELEASED TO THE PUBLIC
|
| 18 |
+
; 10 OCTOBER,2017
|
| 19 |
+
; YEAH, 41 YEARS LATER....
|
| 20 |
+
;
|
| 21 |
+
; @COPYLEFT
|
| 22 |
+
; ALL WRONGS RESERVED
|
| 23 |
+
;
|
| 24 |
+
;*************************************************************
|
| 25 |
+
; This code is derived from the original 8080 Tiny Basic.
|
| 26 |
+
; It was first compiled in 8080 Mnemonics, then disassembled
|
| 27 |
+
; into Zilog Mnemonics. And then checked against the original
|
| 28 |
+
; to ensure accuracy. It was then partially enhanced with z80
|
| 29 |
+
; specific code. And once done, it was then modified to work
|
| 30 |
+
; with the G80-S Micro Computer. However, that portion of the
|
| 31 |
+
; code has been left out in order to make this code a little
|
| 32 |
+
; more portable. There are only three routines that one needs
|
| 33 |
+
; to write, and specifing the serial port's I/O address, in
|
| 34 |
+
; order to make this version work with your own DIY computer.
|
| 35 |
+
; Those routines can be found at the end of the source code.
|
| 36 |
+
;
|
| 37 |
+
; I hope you find good use for this relic. However, I would
|
| 38 |
+
; ask that if you do find use for it, please put a reference
|
| 39 |
+
; to me in your work. And please, distribute freely.
|
| 40 |
+
;*************************************************************
|
| 41 |
+
; Notes for JTFrame version:
|
| 42 |
+
; Adapted to work with GNU z80asm
|
| 43 |
+
; Added interrupt handling
|
| 44 |
+
|
| 45 |
+
SerialPort: EQU 0F0H ; This the serial output port
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
SPACE: EQU 020H ; Space
|
| 49 |
+
TAB: EQU 09H ; HORIZONTAL TAB
|
| 50 |
+
CTRLC: EQU 03H ; Control "C"
|
| 51 |
+
CTRLG: EQU 07H ; Control "G"
|
| 52 |
+
BKSP: EQU 08H ; Back space
|
| 53 |
+
LF: EQU 0AH ; Line feed
|
| 54 |
+
CS: EQU 0CH ; Clear screen
|
| 55 |
+
CR: EQU 0DH ; Carriage return
|
| 56 |
+
CTRLO: EQU 0FH ; Control "O"
|
| 57 |
+
CTRLQ: EQU 011H ; Control "Q"
|
| 58 |
+
CTRLR: EQU 012H ; Control "R"
|
| 59 |
+
CTRLS: EQU 013H ; Control "S"
|
| 60 |
+
CTRLU: EQU 015H ; Control "U"
|
| 61 |
+
ESC: EQU 01BH ; Escape
|
| 62 |
+
DEL: EQU 07FH ; Delete
|
| 63 |
+
|
| 64 |
+
; Adjust to fit RAM mapping
|
| 65 |
+
STACK: EQU 087FFH ; STACK (Last RAM address)
|
| 66 |
+
OCSW: EQU 08000H ;SWITCH FOR OUTPUT
|
| 67 |
+
CURRNT: EQU OCSW+1 ;POINTS FOR OUTPUT
|
| 68 |
+
STKGOS: EQU OCSW+3 ;SAVES SP IN 'GOSUB'
|
| 69 |
+
VARNXT: EQU OCSW+5 ;TEMP STORAGE
|
| 70 |
+
STKINP: EQU OCSW+7 ;SAVES SP IN 'INPUT'
|
| 71 |
+
LOPVAR: EQU OCSW+9 ;'FOR' LOOP SAVE AREA
|
| 72 |
+
LOPINC: EQU OCSW+11 ;INCREMENT
|
| 73 |
+
LOPLMT: EQU OCSW+13 ;LIMIT
|
| 74 |
+
LOPLN: EQU OCSW+15 ;LINE NUMBER
|
| 75 |
+
LOPPT: EQU OCSW+17 ;TEXT POINTER
|
| 76 |
+
RANPNT: EQU OCSW+19 ;RANDOM NUMBER POINTER
|
| 77 |
+
TXTUNF: EQU OCSW+21 ;->UNFILLED TEXT AREA
|
| 78 |
+
TXTBGN: EQU OCSW+23 ;TEXT SAVE AREA BEGINS
|
| 79 |
+
|
| 80 |
+
TXTEND: EQU 08700H ;TEXT SAVE AREA ENDS
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
;*************************************************************
|
| 84 |
+
; *** ZERO PAGE SUBROUTINES ***
|
| 85 |
+
;
|
| 86 |
+
; THE Z80 INSTRUCTION SET ALLOWS FOR 8 ROUTINES IN LOW MEMORY
|
| 87 |
+
; THAT MAY BE CALLED BY RST 00H, 08H, 10H, 18H, 20H, 28H, 30H,
|
| 88 |
+
; AND 38H. THIS IS A ONE BYTE INSTRUCTION, AND IS FUNCTIONALLY
|
| 89 |
+
; SIMILAR TO THE THREE BYTE INSTRUCTION 'CALL XXXX'. TINY BASIC
|
| 90 |
+
; WILL USE THE RST INSTRUCTION FOR THE 7 MOST FREQUENTLY USED
|
| 91 |
+
; SUBROUTINES. TWO OTHER SUBROUTINES (CRLF & TSTNUM) ARE ALSO
|
| 92 |
+
; IN THIS SECTION. THEY CAN BE REACHED WITH 'CALL'.
|
| 93 |
+
;*************************************************************
|
| 94 |
+
|
| 95 |
+
DWA: MACRO WHERE
|
| 96 |
+
DB (WHERE >> 8) + 128
|
| 97 |
+
DB WHERE & 0FFH
|
| 98 |
+
ENDM
|
| 99 |
+
|
| 100 |
+
ORG 0000H
|
| 101 |
+
|
| 102 |
+
START:
|
| 103 |
+
LD SP,STACK ;*** COLD START ***
|
| 104 |
+
LD A,0FFH
|
| 105 |
+
JP INIT
|
| 106 |
+
|
| 107 |
+
RST08: EX (SP),HL ;*** TSTC OR RST 08H ***
|
| 108 |
+
RST 28H ;IGNORE BLANKS AND
|
| 109 |
+
CP (HL) ;TEST CHARACTER
|
| 110 |
+
JP TC1 ;REST OF THIS IS AT TC1
|
| 111 |
+
|
| 112 |
+
CRLF:
|
| 113 |
+
LD A,CR ;*** CRLF ***
|
| 114 |
+
|
| 115 |
+
RST10: PUSH AF ;*** OUTC OR RST 10H ***
|
| 116 |
+
LD A,(OCSW) ;PRINT CHARACTER ONLY
|
| 117 |
+
OR A ;IF OCSW SWITCH IS ON
|
| 118 |
+
JP OUTC ;REST OF THIS AT OUTC
|
| 119 |
+
|
| 120 |
+
RST18: CALL EXPR2 ;*** EXPR OR RST 18H ***
|
| 121 |
+
PUSH HL ;EVALUATE AN EXPRESSION
|
| 122 |
+
JP EXPR1 ;REST OF IT AT EXPR1
|
| 123 |
+
DB 'W'
|
| 124 |
+
|
| 125 |
+
RST20: LD A,H ;*** COMP OR RST 20H ***
|
| 126 |
+
CP D ;COMPARE HL WITH DE
|
| 127 |
+
RET NZ ;RETURN CORRECT C AND
|
| 128 |
+
LD A,L ;Z FLAGS
|
| 129 |
+
CP E ;BUT OLD A IS LOST
|
| 130 |
+
RET
|
| 131 |
+
DB 'AN'
|
| 132 |
+
|
| 133 |
+
SS1:
|
| 134 |
+
RST28: LD A,(DE) ;*** IGNBLK/RST 28H ***
|
| 135 |
+
CP 20H ;IGNORE BLANKS
|
| 136 |
+
RET NZ ;IN TEXT (WHERE DE->)
|
| 137 |
+
INC DE ;AND RETURN THE FIRST
|
| 138 |
+
JP SS1 ;NON-BLANK CHAR. IN A
|
| 139 |
+
|
| 140 |
+
RST30: POP AF ;*** FINISH/RST 30H ***
|
| 141 |
+
CALL FIN ;CHECK END OF COMMAND
|
| 142 |
+
JP QWHAT ;PRINT "WHAT?" IF WRONG
|
| 143 |
+
DB 'G'
|
| 144 |
+
|
| 145 |
+
RST38: RST 28H ;*** TSTV OR RST 38H ***
|
| 146 |
+
SUB 40H ;TEST VARIABLES
|
| 147 |
+
RET C ;C:NOT A VARIABLE
|
| 148 |
+
JR NZ,TV1 ;NOT "@" ARRAY
|
| 149 |
+
INC DE ;IT IS THE "@" ARRAY
|
| 150 |
+
CALL PARN ;@ SHOULD BE FOLLOWED
|
| 151 |
+
ADD HL,HL ;BY (EXPR) AS ITS INDEX
|
| 152 |
+
JR C,QHOW ;IS INDEX TOO BIG?
|
| 153 |
+
PUSH DE ;WILL IT OVERWRITE
|
| 154 |
+
EX DE,HL ;TEXT?
|
| 155 |
+
CALL SIZE ;FIND SIZE OF FREE
|
| 156 |
+
RST 20H ;AND CHECK THAT
|
| 157 |
+
JP C,ASORRY ;IF SO, SAY "SORRY"
|
| 158 |
+
LD HL,VARBGN ;IF NOT GET ADDRESS
|
| 159 |
+
CALL SUBDE ;OF @(EXPR) AND PUT IT
|
| 160 |
+
POP DE ;IN HL
|
| 161 |
+
RET ;C FLAG IS CLEARED
|
| 162 |
+
|
| 163 |
+
TV1:
|
| 164 |
+
CP 1BH ;NOT @, IS IT A TO Z?
|
| 165 |
+
CCF ;IF NOT RETURN C FLAG
|
| 166 |
+
RET C
|
| 167 |
+
INC DE ;IF A THROUGH Z
|
| 168 |
+
LD HL,VARBGN ;COMPUTE ADDRESS OF
|
| 169 |
+
RLCA ;THAT VARIABLE
|
| 170 |
+
ADD A,L ;AND RETURN IT IN HL
|
| 171 |
+
LD L,A ;WITH C FLAG CLEARED
|
| 172 |
+
LD A,00H
|
| 173 |
+
ADC A,H
|
| 174 |
+
LD H,A
|
| 175 |
+
RET
|
| 176 |
+
|
| 177 |
+
NMI66: ;MUST BE AT 66H
|
| 178 |
+
RETI
|
| 179 |
+
|
| 180 |
+
TC1:
|
| 181 |
+
INC HL ;COMPARE THE BYTE THAT
|
| 182 |
+
JR Z,TC2 ;FOLLOWS THE RST INST.
|
| 183 |
+
PUSH BC ;WITH THE TEXT (DE->)
|
| 184 |
+
LD C,(HL) ;IF NOT =, ADD THE 2ND
|
| 185 |
+
LD B,00H ;BYTE THAT FOLLOWS THE
|
| 186 |
+
ADD HL,BC ;RST TO THE OLD PC
|
| 187 |
+
POP BC ;I.E., DO A RELATIVE
|
| 188 |
+
DEC DE ;JUMP IF NOT =
|
| 189 |
+
|
| 190 |
+
TC2:
|
| 191 |
+
INC DE ;IF =, SKIP THOSE BYTES
|
| 192 |
+
INC HL ;AND CONTINUE
|
| 193 |
+
EX (SP),HL
|
| 194 |
+
RET
|
| 195 |
+
|
| 196 |
+
TSTNUM:
|
| 197 |
+
LD HL,0000H ;*** TSTNUM ***
|
| 198 |
+
LD B,H ;TEST IF THE TEXT IS
|
| 199 |
+
RST 28H ;A NUMBER
|
| 200 |
+
|
| 201 |
+
TN1:
|
| 202 |
+
CP 30H ;IF NOT, RETURN 0 IN
|
| 203 |
+
RET C ;B AND HL
|
| 204 |
+
CP 3AH ;IF NUMBERS, CONVERT
|
| 205 |
+
RET NC ;TO BINARY IN HL AND
|
| 206 |
+
LD A,0F0H ;SET B TO # OF DIGITS
|
| 207 |
+
AND H ;IF H>255, THERE IS NO
|
| 208 |
+
JR NZ,QHOW ;ROOM FOR NEXT DIGIT
|
| 209 |
+
INC B ;B COUNTS # OF DIGITS
|
| 210 |
+
PUSH BC
|
| 211 |
+
LD B,H ;HL=10*HL+(NEW DIGIT)
|
| 212 |
+
LD C,L
|
| 213 |
+
ADD HL,HL ;WHERE 10* IS DONE BY
|
| 214 |
+
ADD HL,HL ;SHIFT AND ADD
|
| 215 |
+
ADD HL,BC
|
| 216 |
+
ADD HL,HL
|
| 217 |
+
LD A,(DE) ;AND (DIGIT) IS FROM
|
| 218 |
+
INC DE ;STRIPPING THE ASCII
|
| 219 |
+
AND 0FH ;CODE
|
| 220 |
+
ADD A,L
|
| 221 |
+
LD L,A
|
| 222 |
+
LD A,00H
|
| 223 |
+
ADC A,H
|
| 224 |
+
LD H,A
|
| 225 |
+
POP BC
|
| 226 |
+
LD A,(DE) ;DO THIS DIGIT AFTER
|
| 227 |
+
JP P,TN1 ;DIGIT. S SAYS OVERFLOW
|
| 228 |
+
|
| 229 |
+
QHOW:
|
| 230 |
+
PUSH DE ;*** ERROR "HOW?" ***
|
| 231 |
+
AHOW:
|
| 232 |
+
LD DE,HOW
|
| 233 |
+
JP ERROR_ROUTINE
|
| 234 |
+
|
| 235 |
+
|
| 236 |
+
HOW: DB "HOW?",CR
|
| 237 |
+
OK: DB "OK",CR
|
| 238 |
+
WHAT: DB "WHAT?",CR
|
| 239 |
+
SORRY: DB "SORRY",CR
|
| 240 |
+
|
| 241 |
+
;*************************************************************
|
| 242 |
+
;
|
| 243 |
+
; *** MAIN ***
|
| 244 |
+
;
|
| 245 |
+
; THIS IS THE MAIN LOOP THAT COLLECTS THE TINY BASIC PROGRAM
|
| 246 |
+
; AND STORES IT IN THE MEMORY.
|
| 247 |
+
;
|
| 248 |
+
; AT START, IT PRINTS OUT "(CR)OK(CR)", AND INITIALIZES THE
|
| 249 |
+
; STACK AND SOME OTHER INTERNAL VARIABLES. THEN IT PROMPTS
|
| 250 |
+
; ">" AND READS A LINE. IF THE LINE STARTS WITH A NON-ZERO
|
| 251 |
+
; NUMBER, THIS NUMBER IS THE LINE NUMBER. THE LINE NUMBER
|
| 252 |
+
; (IN 16 BIT BINARY) AND THE REST OF THE LINE (INCLUDING CR)
|
| 253 |
+
; IS STORED IN THE MEMORY. IF A LINE WITH THE SAME LINE
|
| 254 |
+
; NUMBER IS ALREADY THERE, IT IS REPLACED BY THE NEW ONE. IF
|
| 255 |
+
; THE REST OF THE LINE CONSISTS OF A CR ONLY, IT IS NOT STORED
|
| 256 |
+
; AND ANY EXISTING LINE WITH THE SAME LINE NUMBER IS DELETED.
|
| 257 |
+
;
|
| 258 |
+
; AFTER A LINE IS INSERTED, REPLACED, OR DELETED, THE PROGRAM
|
| 259 |
+
; LOOPS BACK AND ASKS FOR ANOTHER LINE. THIS LOOP WILL BE
|
| 260 |
+
; TERMINATED WHEN IT READS A LINE WITH ZERO OR NO LINE
|
| 261 |
+
; NUMBER; AND CONTROL IS TRANSFERED TO "DIRECT".
|
| 262 |
+
;
|
| 263 |
+
; TINY BASIC PROGRAM SAVE AREA STARTS AT THE MEMORY LOCATION
|
| 264 |
+
; LABELED "TXTBGN" AND ENDS AT "TXTEND". WE ALWAYS FILL THIS
|
| 265 |
+
; AREA STARTING AT "TXTBGN", THE UNFILLED PORTION IS POINTED
|
| 266 |
+
; BY THE CONTENT OF A MEMORY LOCATION LABELED "TXTUNF".
|
| 267 |
+
;
|
| 268 |
+
; THE MEMORY LOCATION "CURRNT" POINTS TO THE LINE NUMBER
|
| 269 |
+
; THAT IS CURRENTLY BEING INTERPRETED. WHILE WE ARE IN
|
| 270 |
+
; THIS LOOP OR WHILE WE ARE INTERPRETING A DIRECT COMMAND
|
| 271 |
+
; (SEE NEXT SECTION). "CURRNT" SHOULD POINT TO A 0.
|
| 272 |
+
;*************************************************************
|
| 273 |
+
|
| 274 |
+
RSTART:
|
| 275 |
+
LD SP,STACK
|
| 276 |
+
|
| 277 |
+
ST1:
|
| 278 |
+
CALL CRLF ;AND JUMP TO HERE
|
| 279 |
+
LD DE,OK ;DE->STRING
|
| 280 |
+
SUB A ;A=0
|
| 281 |
+
CALL PRTSTG ;PRINT STRING UNTIL CR
|
| 282 |
+
LD HL,ST2+1 ;LITERAL 0
|
| 283 |
+
LD (CURRNT),HL ;CURRENT->LINE # = 0
|
| 284 |
+
|
| 285 |
+
ST2:
|
| 286 |
+
LD HL,0000H
|
| 287 |
+
LD (LOPVAR),HL
|
| 288 |
+
LD (STKGOS),HL
|
| 289 |
+
|
| 290 |
+
ST3:
|
| 291 |
+
LD A,'>' ;PROMPT '>' AND
|
| 292 |
+
CALL GETLN ;READ A LINE
|
| 293 |
+
PUSH DE ;DE->END OF LINE
|
| 294 |
+
LD DE,BUFFER ;DE->BEGINNING OF LINE
|
| 295 |
+
CALL TSTNUM ;TEST IF IT IS A NUMBER
|
| 296 |
+
RST 28H
|
| 297 |
+
LD A,H ;HL=VALUE OF THE # OR
|
| 298 |
+
OR L ;0 IF NO # WAS FOUND
|
| 299 |
+
POP BC ;BC->END OF LINE
|
| 300 |
+
JP Z,DIRECT
|
| 301 |
+
DEC DE ;BACKUP DE AND SAVE
|
| 302 |
+
LD A,H ;VALUE OF LINE # THERE
|
| 303 |
+
LD (DE),A
|
| 304 |
+
DEC DE
|
| 305 |
+
LD A,L
|
| 306 |
+
LD (DE),A
|
| 307 |
+
PUSH BC ;BC,DE->BEGIN, END
|
| 308 |
+
PUSH DE
|
| 309 |
+
LD A,C
|
| 310 |
+
SUB E
|
| 311 |
+
|
| 312 |
+
PUSH AF ;A=# OF BYTES IN LINE
|
| 313 |
+
CALL FNDLN ;FIND THIS LINE IN SAVE
|
| 314 |
+
PUSH DE ;AREA, DE->SAVE AREA
|
| 315 |
+
JR NZ,ST4 ;NZ:NOT FOUND, INSERT
|
| 316 |
+
PUSH DE ;Z:FOUND, DELETE IT
|
| 317 |
+
CALL FNDNXT ;FIND NEXT LINE
|
| 318 |
+
;DE->NEXT LINE
|
| 319 |
+
POP BC ;BC->LINE TO BE DELETED
|
| 320 |
+
LD HL,(TXTUNF) ;HL->UNFILLED SAVE AREA
|
| 321 |
+
CALL MVUP ;MOVE UP TO DELETE
|
| 322 |
+
LD H,B ;TXTUNF->UNFILLED ARA
|
| 323 |
+
LD L,C
|
| 324 |
+
LD (TXTUNF),HL ;UPDATE
|
| 325 |
+
|
| 326 |
+
ST4:
|
| 327 |
+
POP BC ;GET READY TO INSERT
|
| 328 |
+
LD HL,(TXTUNF) ;BUT FIRST CHECK IF
|
| 329 |
+
POP AF ;THE LENGTH OF NEW LINE
|
| 330 |
+
PUSH HL ;IS 3 (LINE # AND CR)
|
| 331 |
+
CP 03H ;THEN DO NOT INSERT
|
| 332 |
+
JR Z,RSTART ;MUST CLEAR THE STACK
|
| 333 |
+
ADD A,L ;COMPUTE NEW TXTUNF
|
| 334 |
+
LD L,A
|
| 335 |
+
LD A,00H
|
| 336 |
+
ADC A,H
|
| 337 |
+
LD H,A ;HL->NEW UNFILLED AREA
|
| 338 |
+
LD DE,TXTEND ;CHECK TO SEE IF THERE
|
| 339 |
+
RST 20H ;IS ENOUGH SPACE
|
| 340 |
+
JP NC,QSORRY ;SORRY, NO ROOM FOR IT
|
| 341 |
+
LD (TXTUNF),HL ;OK, UPDATE TXTUNF
|
| 342 |
+
POP DE ;DE->OLD UNFILLED AREA
|
| 343 |
+
CALL MVDOWN
|
| 344 |
+
POP DE ;DE->BEGIN, HL->END
|
| 345 |
+
POP HL
|
| 346 |
+
CALL MVUP ;MOVE NEW LINE TO SAVE
|
| 347 |
+
JR ST3 ;AREA
|
| 348 |
+
|
| 349 |
+
;*************************************************************
|
| 350 |
+
;
|
| 351 |
+
; WHAT FOLLOWS IS THE CODE TO EXECUTE DIRECT AND STATEMENT
|
| 352 |
+
; COMMANDS. CONTROL IS TRANSFERED TO THESE POINTS VIA THE
|
| 353 |
+
; COMMAND TABLE LOOKUP CODE OF 'DIRECT' AND 'EXEC' IN LAST
|
| 354 |
+
; SECTION. AFTER THE COMMAND IS EXECUTED, CONTROL IS
|
| 355 |
+
; TRANSFERED TO OTHERS SECTIONS AS FOLLOWS:
|
| 356 |
+
;
|
| 357 |
+
; FOR 'LIST', 'NEW', AND 'STOP': GO BACK TO 'RSTART'
|
| 358 |
+
; FOR 'RUN': GO EXECUTE THE FIRST STORED LINE IF ANY, ELSE
|
| 359 |
+
; GO BACK TO 'RSTART'.
|
| 360 |
+
; FOR 'GOTO' AND 'GOSUB': GO EXECUTE THE TARGET LINE.
|
| 361 |
+
; FOR 'RETURN' AND 'NEXT': GO BACK TO SAVED RETURN LINE.
|
| 362 |
+
; FOR ALL OTHERS: IF 'CURRENT' -> 0, GO TO 'RSTART', ELSE
|
| 363 |
+
; GO EXECUTE NEXT COMMAND. (THIS IS DONE IN 'FINISH'.)
|
| 364 |
+
;*************************************************************
|
| 365 |
+
;
|
| 366 |
+
; *** NEW *** STOP *** RUN (& FRIENDS) *** & GOTO ***
|
| 367 |
+
;
|
| 368 |
+
; 'NEW(CR)' SETS 'TXTUNF' TO POINT TO 'TXTBGN'
|
| 369 |
+
;
|
| 370 |
+
; 'STOP(CR)' GOES BACK TO 'RSTART'
|
| 371 |
+
;
|
| 372 |
+
; 'RUN(CR)' FINDS THE FIRST STORED LINE, STORE ITS ADDRESS (IN
|
| 373 |
+
; 'CURRENT'), AND START EXECUTE IT. NOTE THAT ONLY THOSE
|
| 374 |
+
; COMMANDS IN TAB2 ARE LEGAL FOR STORED PROGRAM.
|
| 375 |
+
;
|
| 376 |
+
; THERE ARE 3 MORE ENTRIES IN 'RUN':
|
| 377 |
+
; 'RUNNXL' FINDS NEXT LINE, STORES ITS ADDR. AND EXECUTES IT.
|
| 378 |
+
; 'RUNTSL' STORES THE ADDRESS OF THIS LINE AND EXECUTES IT.
|
| 379 |
+
; 'RUNSML' CONTINUES THE EXECUTION ON SAME LINE.
|
| 380 |
+
;
|
| 381 |
+
; 'GOTO EXPR(CR)' EVALUATES THE EXPRESSION, FIND THE TARGET
|
| 382 |
+
; LINE, AND JUMP TO 'RUNTSL' TO DO IT.
|
| 383 |
+
;*************************************************************
|
| 384 |
+
|
| 385 |
+
NEW:
|
| 386 |
+
CALL ENDCHK ;*** NEW(CR) ***
|
| 387 |
+
LD HL,TXTBGN
|
| 388 |
+
LD (TXTUNF),HL
|
| 389 |
+
STOP:
|
| 390 |
+
CALL ENDCHK ;*** STOP(CR) ***
|
| 391 |
+
JP RSTART
|
| 392 |
+
RUN:
|
| 393 |
+
CALL ENDCHK ;*** RUN(CR) ***
|
| 394 |
+
LD DE,TXTBGN ;FIRST SAVED LINE
|
| 395 |
+
RUNNXL:
|
| 396 |
+
LD HL,00H ;*** RUNNXL ***
|
| 397 |
+
CALL FNDLP ;FIND WHATEVER LINE #
|
| 398 |
+
JP C,RSTART ;C:PASSED TXTUNF, QUIT
|
| 399 |
+
RUNTSL:
|
| 400 |
+
EX DE,HL ;*** RUNTSL ***
|
| 401 |
+
LD (CURRNT),HL ;SET 'CURRENT'->LINE #
|
| 402 |
+
EX DE,HL
|
| 403 |
+
INC DE ;BUMP PASS LINE #
|
| 404 |
+
INC DE
|
| 405 |
+
RUNSML:
|
| 406 |
+
CALL CHKIO ;*** RUNSML ***
|
| 407 |
+
LD HL,TAB2-1 ;FIND COMMAND IN TAB2
|
| 408 |
+
JP EXEC ;AND EXECUTE IT
|
| 409 |
+
GOTO:
|
| 410 |
+
RST 18H ;*** GOTO EXPR ***
|
| 411 |
+
PUSH DE ;SAVE FOR ERROR ROUTINE
|
| 412 |
+
CALL ENDCHK ;MUST FIND A CR
|
| 413 |
+
CALL FNDLN ;FIND THE TARGET LINE
|
| 414 |
+
JP NZ,AHOW ;NO SUCH LINE #
|
| 415 |
+
POP AF ;CLEAR THE PUSH DE
|
| 416 |
+
JR RUNTSL ;GO DO IT
|
| 417 |
+
|
| 418 |
+
;*************************************************************
|
| 419 |
+
;
|
| 420 |
+
; *** LIST *** & PRINT ***
|
| 421 |
+
;
|
| 422 |
+
; LIST HAS TWO FORMS:
|
| 423 |
+
; 'LIST(CR)' LISTS ALL SAVED LINES
|
| 424 |
+
; 'LIST #(CR)' START LIST AT THIS LINE #
|
| 425 |
+
; YOU CAN STOP THE LISTING BY CONTROL C KEY
|
| 426 |
+
;
|
| 427 |
+
; PRINT COMMAND IS 'PRINT ....;' OR 'PRINT ....(CR)'
|
| 428 |
+
; WHERE '....' IS A LIST OF EXPRESIONS, FORMATS, BACK-
|
| 429 |
+
; ARROWS, AND STRINGS. THESE ITEMS ARE SEPERATED BY COMMAS.
|
| 430 |
+
;
|
| 431 |
+
; A FORMAT IS A POUND SIGN FOLLOWED BY A NUMBER. IT CONTROLS
|
| 432 |
+
; THE NUMBER OF SPACES THE VALUE OF A EXPRESION IS GOING TO
|
| 433 |
+
; BE PRINTED. IT STAYS EFFECTIVE FOR THE REST OF THE PRINT
|
| 434 |
+
; COMMAND UNLESS CHANGED BY ANOTHER FORMAT. IF NO FORMAT IS
|
| 435 |
+
; SPECIFIED, 6 POSITIONS WILL BE USED.
|
| 436 |
+
;
|
| 437 |
+
; A STRING IS QUOTED IN A PAIR OF SINGLE QUOTES OR A PAIR OF
|
| 438 |
+
; DOUBLE QUOTES.
|
| 439 |
+
;
|
| 440 |
+
; A BACK-ARROW MEANS GENERATE A (CR) WITHOUT (LF)
|
| 441 |
+
;
|
| 442 |
+
; A (CRLF) IS GENERATED AFTER THE ENTIRE LIST HAS BEEN
|
| 443 |
+
; PRINTED OR IF THE LIST IS A NULL LIST. HOWEVER IF THE LIST
|
| 444 |
+
; ENDED WITH A COMMA, NO (CRLF) IS GENERATED.
|
| 445 |
+
;*************************************************************
|
| 446 |
+
|
| 447 |
+
LIST:
|
| 448 |
+
CALL TSTNUM ;TEST IF THERE IS A #
|
| 449 |
+
CALL ENDCHK ;IF NO # WE GET A 0
|
| 450 |
+
CALL FNDLN ;FIND THIS OR NEXT LINE
|
| 451 |
+
LS1:
|
| 452 |
+
JP C,RSTART ;C:PASSED TXTUNF
|
| 453 |
+
CALL PRTLN ;PRINT THE LINE
|
| 454 |
+
CALL CHKIO ;STOP IF HIT CONTROL-C
|
| 455 |
+
CALL FNDLP ;FIND NEXT LINE
|
| 456 |
+
JR LS1 ;AND LOOP BACK
|
| 457 |
+
PRINT:
|
| 458 |
+
LD C,06H ;C = # OF SPACES
|
| 459 |
+
RST 08H ;F NULL LIST & ";"
|
| 460 |
+
DB 3BH
|
| 461 |
+
DB PR2-$-1
|
| 462 |
+
CALL CRLF ;GIVE CR-LF AND
|
| 463 |
+
JR RUNSML ;CONTINUE SAME LINE
|
| 464 |
+
PR2:
|
| 465 |
+
RST 08H ;IF NULL LIST (CR)
|
| 466 |
+
DB CR
|
| 467 |
+
DB PR0-$-1
|
| 468 |
+
CALL CRLF ;ALSO GIVE CR-LF AND
|
| 469 |
+
JR RUNNXL ;GO TO NEXT LINE
|
| 470 |
+
PR0:
|
| 471 |
+
RST 08H ;ELSE IS IT FORMAT?
|
| 472 |
+
DB '#'
|
| 473 |
+
DB PR1-$-1
|
| 474 |
+
RST 18H ;YES, EVALUATE EXPR.
|
| 475 |
+
LD C,L ;AND SAVE IT IN C
|
| 476 |
+
JR PR3 ;LOOK FOR MORE TO PRINT
|
| 477 |
+
PR1:
|
| 478 |
+
CALL QTSTG ;OR IS IT A STRING?
|
| 479 |
+
JR PR8 ;IF NOT, MUST BE EXPR.
|
| 480 |
+
PR3:
|
| 481 |
+
RST 08H ;IF ",", GO FIND NEXT
|
| 482 |
+
DB ','
|
| 483 |
+
DB PR6-$-1
|
| 484 |
+
CALL FIN ;IN THE LIST.
|
| 485 |
+
JR PR0 ;LIST CONTINUES
|
| 486 |
+
PR6:
|
| 487 |
+
CALL CRLF ;LIST ENDS
|
| 488 |
+
RST 30H
|
| 489 |
+
PR8:
|
| 490 |
+
RST 18H ;EVALUATE THE EXPR
|
| 491 |
+
PUSH BC
|
| 492 |
+
CALL PRTNUM ;PRINT THE VALUE
|
| 493 |
+
POP BC
|
| 494 |
+
JR PR3 ;MORE TO PRINT?
|
| 495 |
+
|
| 496 |
+
;*************************************************************
|
| 497 |
+
;
|
| 498 |
+
; *** GOSUB *** & RETURN ***
|
| 499 |
+
;
|
| 500 |
+
; 'GOSUB EXPR;' OR 'GOSUB EXPR (CR)' IS LIKE THE 'GOTO'
|
| 501 |
+
; COMMAND, EXCEPT THAT THE CURRENT TEXT POINTER, STACK POINTER
|
| 502 |
+
; ETC. ARE SAVE SO THAT EXECUTION CAN BE CONTINUED AFTER THE
|
| 503 |
+
; SUBROUTINE 'RETURN'. IN ORDER THAT 'GOSUB' CAN BE NESTED
|
| 504 |
+
; (AND EVEN RECURSIVE), THE SAVE AREA MUST BE STACKED.
|
| 505 |
+
; THE STACK POINTER IS SAVED IN 'STKGOS', THE OLD 'STKGOS' IS
|
| 506 |
+
; SAVED IN THE STACK. IF WE ARE IN THE MAIN ROUTINE, 'STKGOS'
|
| 507 |
+
; IS ZERO (THIS WAS DONE BY THE "MAIN" SECTION OF THE CODE),
|
| 508 |
+
; BUT WE STILL SAVE IT AS A FLAG FOR NO FURTHER 'RETURN'S.
|
| 509 |
+
;
|
| 510 |
+
; 'RETURN(CR)' UNDOS EVERYTHING THAT 'GOSUB' DID, AND THUS
|
| 511 |
+
; RETURN THE EXECUTION TO THE COMMAND AFTER THE MOST RECENT
|
| 512 |
+
; 'GOSUB'. IF 'STKGOS' IS ZERO, IT INDICATES THAT WE
|
| 513 |
+
; NEVER HAD A 'GOSUB' AND IS THUS AN ERROR.
|
| 514 |
+
;*************************************************************
|
| 515 |
+
|
| 516 |
+
GOSUB:
|
| 517 |
+
CALL PUSHA ;SAVE THE CURRENT "FOR"
|
| 518 |
+
RST 18H ;PARAMETERS
|
| 519 |
+
PUSH DE ;AND TEXT POINTER
|
| 520 |
+
CALL FNDLN ;FIND THE TARGET LINE
|
| 521 |
+
JP NZ,AHOW ;NOT THERE. SAY "HOW?"
|
| 522 |
+
LD HL,(CURRNT) ;FOUND IT, SAVE OLD.
|
| 523 |
+
PUSH HL ;'CURRNT' OLD 'STKGOS'
|
| 524 |
+
LD HL,(STKGOS)
|
| 525 |
+
PUSH HL
|
| 526 |
+
LD HL,0000H ;AND LOAD NEW ONES
|
| 527 |
+
LD (LOPVAR),HL
|
| 528 |
+
ADD HL,SP
|
| 529 |
+
LD (STKGOS),HL
|
| 530 |
+
JP RUNTSL ;THEN RUN THAT LINE
|
| 531 |
+
RETURN:
|
| 532 |
+
CALL ENDCHK ;THERE MUST BE A CR
|
| 533 |
+
LD HL,(STKGOS) ;OLD STACK POINTER
|
| 534 |
+
LD A,H ;0 MEANS NOT EXIST
|
| 535 |
+
OR L
|
| 536 |
+
JP Z,QWHAT ;SO, WE SAY: "WHAT?"
|
| 537 |
+
LD SP,HL ;ELSE, RESTORE IT
|
| 538 |
+
POP HL
|
| 539 |
+
LD (STKGOS),HL ;AND THE OLD "STKGOS"
|
| 540 |
+
POP HL
|
| 541 |
+
LD (CURRNT),HL ;AND THE OLD 'CURRNT'
|
| 542 |
+
POP DE ;OLD TEXT POINTER
|
| 543 |
+
CALL POPA ;OLD "FOR" PARAMETERS
|
| 544 |
+
RST 30H ;AND WE ARE BACK HOME
|
| 545 |
+
|
| 546 |
+
;*************************************************************
|
| 547 |
+
;
|
| 548 |
+
; *** FOR *** & NEXT ***
|
| 549 |
+
;
|
| 550 |
+
; 'FOR' HAS TWO FORMS:
|
| 551 |
+
; 'FOR VAR=EXP1 TO EXP2 STEP EXP3' AND 'FOR VAR=EXP1 TO EXP2'
|
| 552 |
+
; THE SECOND FORM MEANS THE SAME THING AS THE FIRST FORM WITH
|
| 553 |
+
; EXP3=1. (I.E., WITH A STEP OF +1.)
|
| 554 |
+
; TBI WILL FIND THE VARIABLE VAR, AND SET ITS VALUE TO THE
|
| 555 |
+
; CURRENT VALUE OF EXP1. IT ALSO EVALUATES EXP2 AND EXP3
|
| 556 |
+
; AND SAVE ALL THESE TOGETHER WITH THE TEXT POINTER ETC. IN
|
| 557 |
+
; THE 'FOR' SAVE AREA, WHICH CONSISTS OF 'LOPVAR', 'LOPINC',
|
| 558 |
+
; 'LOPLMT', 'LOPLN', AND 'LOPPT'. IF THERE IS ALREADY SOME-
|
| 559 |
+
; THING IN THE SAVE AREA (THIS IS INDICATED BY A NON-ZERO
|
| 560 |
+
; 'LOPVAR'), THEN THE OLD SAVE AREA IS SAVED IN THE STACK
|
| 561 |
+
; BEFORE THE NEW ONE OVERWRITES IT.
|
| 562 |
+
; TBI WILL THEN DIG IN THE STACK AND FIND OUT IF THIS SAME
|
| 563 |
+
; VARIABLE WAS USED IN ANOTHER CURRENTLY ACTIVE 'FOR' LOOP.
|
| 564 |
+
; IF THAT IS THE CASE, THEN THE OLD 'FOR' LOOP IS DEACTIVATED.
|
| 565 |
+
; (PURGED FROM THE STACK..)
|
| 566 |
+
;
|
| 567 |
+
; 'NEXT VAR' SERVES AS THE LOGICAL (NOT NECESSARILLY PHYSICAL)
|
| 568 |
+
; END OF THE 'FOR' LOOP. THE CONTROL VARIABLE VAR. IS CHECKED
|
| 569 |
+
; WITH THE 'LOPVAR'. IF THEY ARE NOT THE SAME, TBI DIGS IN
|
| 570 |
+
; THE STACK TO FIND THE RIGHT ONE AND PURGES ALL THOSE THAT
|
| 571 |
+
; DID NOT MATCH. EITHER WAY, TBI THEN ADDS THE 'STEP' TO
|
| 572 |
+
; THAT VARIABLE AND CHECK THE RESULT WITH THE LIMIT. IF IT
|
| 573 |
+
; IS WITHIN THE LIMIT, CONTROL LOOPS BACK TO THE COMMAND
|
| 574 |
+
; FOLLOWING THE 'FOR'. IF OUTSIDE THE LIMIT, THE SAVE AREA
|
| 575 |
+
; IS PURGED AND EXECUTION CONTINUES.
|
| 576 |
+
;*************************************************************
|
| 577 |
+
|
| 578 |
+
FOR:
|
| 579 |
+
CALL PUSHA ;SAVE THE OLD SAVE AREA
|
| 580 |
+
CALL SETVAL ;SET THE CONTROL VAR.
|
| 581 |
+
DEC HL ;HL IS ITS ADDRESS
|
| 582 |
+
LD (LOPVAR),HL ;SAVE THAT
|
| 583 |
+
LD HL,TAB5-1 ;USE 'EXEC' TO LOOK
|
| 584 |
+
JP EXEC ;FOR THE WORK 'TO'
|
| 585 |
+
FR1:
|
| 586 |
+
RST 18H ;EVALUATE THE LIMITE
|
| 587 |
+
LD (LOPLMT),HL ;SAVE THAT
|
| 588 |
+
LD HL,TAB6-1 ;USE 'EXEC' TO LOOK
|
| 589 |
+
JP EXEC ;FOR THE WORD 'STEP'
|
| 590 |
+
FR2:
|
| 591 |
+
RST 18H ;FOUND IT, GET STEP
|
| 592 |
+
JR FR4
|
| 593 |
+
FR3:
|
| 594 |
+
LD HL,0001H ;NOT FOUND, SET TO 1
|
| 595 |
+
FR4:
|
| 596 |
+
LD (LOPINC),HL ;SAVE THAT TOO
|
| 597 |
+
FR5:
|
| 598 |
+
LD HL,(CURRNT) ;SAVE CURRENT LINE #
|
| 599 |
+
LD (LOPLN),HL
|
| 600 |
+
EX DE,HL ;AND TEXT POINTER
|
| 601 |
+
LD (LOPPT),HL
|
| 602 |
+
LD BC,0AH ;DIG INTO STACK TO
|
| 603 |
+
LD HL,(LOPVAR) ;FIND 'LOPVAR'
|
| 604 |
+
EX DE,HL
|
| 605 |
+
LD H,B
|
| 606 |
+
LD L,B ;HL=0 NOW
|
| 607 |
+
ADD HL,SP ;HERE IS THE STACK
|
| 608 |
+
DB 3EH ;DISASSEMBLY SAID "ld a,09h"
|
| 609 |
+
FR7:
|
| 610 |
+
ADD HL,BC ;EACH LEVEL IS 10 DEEP - DIS = 09
|
| 611 |
+
LD A,(HL) ;GET THAT OLD 'LOPVAR'
|
| 612 |
+
INC HL
|
| 613 |
+
OR (HL)
|
| 614 |
+
JR Z,FR8 ;0 SAYS NO MORE IN IT
|
| 615 |
+
LD A,(HL)
|
| 616 |
+
DEC HL
|
| 617 |
+
CP D ;SAME AS THIS ONE?
|
| 618 |
+
JR NZ,FR7
|
| 619 |
+
LD A,(HL) ;THE OTHER HALF?
|
| 620 |
+
CP E
|
| 621 |
+
JR NZ,FR7
|
| 622 |
+
EX DE,HL ;YES, FOUND ONE
|
| 623 |
+
LD HL,0000H
|
| 624 |
+
ADD HL,SP ;TRY TO MOVE SP
|
| 625 |
+
LD B,H
|
| 626 |
+
LD C,L
|
| 627 |
+
LD HL,000AH
|
| 628 |
+
ADD HL,DE
|
| 629 |
+
CALL MVDOWN ;AND PURGE 10 WORDS
|
| 630 |
+
LD SP,HL ;IN THE STACK
|
| 631 |
+
FR8:
|
| 632 |
+
LD HL,(LOPPT) ;JOB DONE, RESTORE DE
|
| 633 |
+
EX DE,HL
|
| 634 |
+
RST 30H ;AND CONTINUE
|
| 635 |
+
;
|
| 636 |
+
NEXT:
|
| 637 |
+
RST 38H ;GET ADDRESS OF VAR.
|
| 638 |
+
JP C,QWHAT ;NO VARIABLE, "WHAT?"
|
| 639 |
+
LD (VARNXT),HL ;YES, SAVE IT
|
| 640 |
+
NX0:
|
| 641 |
+
PUSH DE ;SAVE TEXT POINTER
|
| 642 |
+
EX DE,HL
|
| 643 |
+
LD HL,(LOPVAR) ;GET VAR. IN 'FOR'
|
| 644 |
+
LD A,H
|
| 645 |
+
OR L ;0 SAYS NEVER HAD ONE
|
| 646 |
+
JP Z,AWHAT ;SO WE ASK: "WHAT?"
|
| 647 |
+
RST 20H ;ELSE WE CHECK THEM
|
| 648 |
+
JR Z,NX3 ;OK, THEY AGREE
|
| 649 |
+
POP DE ;NO, LET'S SEE
|
| 650 |
+
CALL POPA ;PURGE CURRENT LOOP
|
| 651 |
+
LD HL,(VARNXT) ;AND POP ONE LEVEL
|
| 652 |
+
JR NX0 ;GO CHECK AGAIN
|
| 653 |
+
NX3:
|
| 654 |
+
LD E,(HL) ;COME HERE WHEN AGREED
|
| 655 |
+
INC HL
|
| 656 |
+
LD D,(HL) ;DE=VALUE OF VAR.
|
| 657 |
+
LD HL,(LOPINC)
|
| 658 |
+
PUSH HL
|
| 659 |
+
LD A,H
|
| 660 |
+
XOR D
|
| 661 |
+
LD A,D
|
| 662 |
+
ADD HL,DE ;ADD ONE STEP
|
| 663 |
+
JP M,NX4
|
| 664 |
+
XOR H
|
| 665 |
+
JP M,NX5
|
| 666 |
+
NX4:
|
| 667 |
+
EX DE,HL
|
| 668 |
+
LD HL,(LOPVAR) ;PUT IT BACK
|
| 669 |
+
LD (HL),E
|
| 670 |
+
INC HL
|
| 671 |
+
LD (HL),D
|
| 672 |
+
LD HL,(LOPLMT) ;HL->LIMIT
|
| 673 |
+
POP AF ;OLD HL
|
| 674 |
+
OR A
|
| 675 |
+
JP P,NX1 ;STEP > 0
|
| 676 |
+
EX DE,HL ;STEP < 0
|
| 677 |
+
NX1:
|
| 678 |
+
CALL CKHLDE ;COMPARE WITH LIMIT
|
| 679 |
+
POP DE ;RESTORE TEXT POINTER
|
| 680 |
+
JR C,NX2 ;OUTSIDE LIMIT
|
| 681 |
+
LD HL,(LOPLN) ;WITHIN LIMIT, GO
|
| 682 |
+
LD (CURRNT),HL ;BACK TO THE SAVED
|
| 683 |
+
LD HL,(LOPPT) ;'CURRNT' AND TEXT
|
| 684 |
+
EX DE,HL ;POINTER
|
| 685 |
+
RST 30H
|
| 686 |
+
NX5:
|
| 687 |
+
POP HL
|
| 688 |
+
POP DE
|
| 689 |
+
NX2:
|
| 690 |
+
CALL POPA ;PURGE THIS LOOP
|
| 691 |
+
RST 30H
|
| 692 |
+
|
| 693 |
+
;*************************************************************
|
| 694 |
+
;
|
| 695 |
+
; *** REM *** IF *** INPUT *** & LET (& DEFLT) ***
|
| 696 |
+
;
|
| 697 |
+
; 'REM' CAN BE FOLLOWED BY ANYTHING AND IS IGNORED BY TBI.
|
| 698 |
+
; TBI TREATS IT LIKE AN 'IF' WITH A FALSE CONDITION.
|
| 699 |
+
;
|
| 700 |
+
; 'IF' IS FOLLOWED BY AN EXPR. AS A CONDITION AND ONE OR MORE
|
| 701 |
+
; COMMANDS (INCLUDING OTHER 'IF'S) SEPERATED BY SEMI-COLONS.
|
| 702 |
+
; NOTE THAT THE WORD 'THEN' IS NOT USED. TBI EVALUATES THE
|
| 703 |
+
; EXPR. IF IT IS NON-ZERO, EXECUTION CONTINUES. IF THE
|
| 704 |
+
; EXPR. IS ZERO, THE COMMANDS THAT FOLLOWS ARE IGNORED AND
|
| 705 |
+
; EXECUTION CONTINUES AT THE NEXT LINE.
|
| 706 |
+
;
|
| 707 |
+
; 'INPUT' COMMAND IS LIKE THE 'PRINT' COMMAND, AND IS FOLLOWED
|
| 708 |
+
; BY A LIST OF ITEMS. IF THE ITEM IS A STRING IN SINGLE OR
|
| 709 |
+
; DOUBLE QUOTES, OR IS A BACK-ARROW, IT HAS THE SAME EFFECT AS
|
| 710 |
+
; IN 'PRINT'. IF AN ITEM IS A VARIABLE, THIS VARIABLE NAME IS
|
| 711 |
+
; PRINTED OUT FOLLOWED BY A COLON. THEN TBI WAITS FOR AN
|
| 712 |
+
; EXPR. TO BE TYPED IN. THE VARIABLE IS THEN SET TO THE
|
| 713 |
+
; VALUE OF THIS EXPR. IF THE VARIABLE IS PROCEDED BY A STRING
|
| 714 |
+
; (AGAIN IN SINGLE OR DOUBLE QUOTES), THE STRING WILL BE
|
| 715 |
+
; PRINTED FOLLOWED BY A COLON. TBI THEN WAITS FOR INPUT EXPR.
|
| 716 |
+
; AND SET THE VARIABLE TO THE VALUE OF THE EXPR.
|
| 717 |
+
;
|
| 718 |
+
; IF THE INPUT EXPR. IS INVALID, TBI WILL PRINT "WHAT?",
|
| 719 |
+
; "HOW?" OR "SORRY" AND REPRINT THE PROMPT AND REDO THE INPUT.
|
| 720 |
+
; THE EXECUTION WILL NOT TERMINATE UNLESS YOU TYPE CONTROL-C.
|
| 721 |
+
; THIS IS HANDLED IN 'INPERR'.
|
| 722 |
+
;
|
| 723 |
+
; 'LET' IS FOLLOWED BY A LIST OF ITEMS SEPERATED BY COMMAS.
|
| 724 |
+
; EACH ITEM CONSISTS OF A VARIABLE, AN EQUAL SIGN, AND AN EXPR.
|
| 725 |
+
; TBI EVALUATES THE EXPR. AND SET THE VARIABLE TO THAT VALUE.
|
| 726 |
+
; TBI WILL ALSO HANDLE 'LET' COMMAND WITHOUT THE WORD 'LET'.
|
| 727 |
+
; THIS IS DONE BY 'DEFLT'.
|
| 728 |
+
;*************************************************************
|
| 729 |
+
|
| 730 |
+
REM:
|
| 731 |
+
LD HL,0000H ;*** REM ***
|
| 732 |
+
DB 3EH ;THIS IS LIKE 'IF 0'
|
| 733 |
+
IFF:
|
| 734 |
+
RST 18H ;*** IF ***
|
| 735 |
+
LD A,H ;IS THE EXPR.=0?
|
| 736 |
+
OR L
|
| 737 |
+
JP NZ,RUNSML ;NO, CONTINUE
|
| 738 |
+
CALL FNDSKP ;YES, SKIP REST OF LINE
|
| 739 |
+
JP NC,RUNTSL ;AND RUN THE NEXT LINE
|
| 740 |
+
JP RSTART ;IF NO NEXT, RE-START
|
| 741 |
+
INPERR:
|
| 742 |
+
LD HL,(STKINP) ;*** INPERR ***
|
| 743 |
+
LD SP,HL ;RESTORE OLD SP
|
| 744 |
+
POP HL ;AND OLD 'CURRNT'
|
| 745 |
+
LD (CURRNT),HL
|
| 746 |
+
POP DE ;AND OLD TEXT POINTER
|
| 747 |
+
POP DE ;REDO INPUT
|
| 748 |
+
INPUT: ;*** INPUT ***
|
| 749 |
+
IP1:
|
| 750 |
+
PUSH DE ;SAVE IN CASE OF ERROR
|
| 751 |
+
CALL QTSTG ;IS NEXT ITEM A STRING?
|
| 752 |
+
JR IP2 ;NO
|
| 753 |
+
RST 38H ;YES, BUT FOLLOWED BY A
|
| 754 |
+
JR C,IP4 ;VARIABLE? NO.
|
| 755 |
+
JR IP3 ;YES. INPUT VARIABLE
|
| 756 |
+
IP2:
|
| 757 |
+
PUSH DE ;SAVE FOR 'PRTSTG'
|
| 758 |
+
RST 38H ;MUST BE VARIABLE NOW
|
| 759 |
+
JP C,QWHAT ;"WHAT?" IT IS NOT?
|
| 760 |
+
LD A,(DE) ;GET READY FOR 'PRTSTR'
|
| 761 |
+
LD C,A
|
| 762 |
+
SUB A
|
| 763 |
+
LD (DE),A
|
| 764 |
+
POP DE
|
| 765 |
+
CALL PRTSTG ;PRINT STRING AS PROMPT
|
| 766 |
+
LD A,C ;RESTORE TEXT
|
| 767 |
+
DEC DE
|
| 768 |
+
LD (DE),A
|
| 769 |
+
IP3:
|
| 770 |
+
PUSH DE ;SAVE TEXT POINTER
|
| 771 |
+
EX DE,HL
|
| 772 |
+
LD HL,(CURRNT) ;ALSO SAVE 'CURRNT'
|
| 773 |
+
PUSH HL
|
| 774 |
+
LD HL,IP1 ;A NEGATIVE NUMBER
|
| 775 |
+
LD (CURRNT),HL ;AS A FLAG
|
| 776 |
+
LD HL,0000H ;SAVE SP TOO
|
| 777 |
+
ADD HL,SP
|
| 778 |
+
LD (STKINP),HL
|
| 779 |
+
PUSH DE ;OLD HL
|
| 780 |
+
LD A,3AH ;PRINT THIS TOO
|
| 781 |
+
CALL GETLN ;AND GET A LINE
|
| 782 |
+
LD DE,BUFFER ;POINTS TO BUFFER
|
| 783 |
+
RST 18H ;EVALUATE INPUT
|
| 784 |
+
NOP ;CAN BE 'CALL ENDCHK'
|
| 785 |
+
NOP
|
| 786 |
+
NOP
|
| 787 |
+
POP DE ;OK,GET OLD HL
|
| 788 |
+
EX DE,HL
|
| 789 |
+
LD (HL),E ;SAVE VALUE IN VAR.
|
| 790 |
+
INC HL
|
| 791 |
+
LD (HL),D
|
| 792 |
+
POP HL ;GET OLD 'CURRNT'
|
| 793 |
+
LD (CURRNT),HL
|
| 794 |
+
POP DE ;AND OLD TEXT POINTER
|
| 795 |
+
IP4:
|
| 796 |
+
POP AF ;PURGE JUNK IN STACK
|
| 797 |
+
RST 08H ;IS NEXT CH. ','?
|
| 798 |
+
DB ','
|
| 799 |
+
DB IP5-$-1
|
| 800 |
+
JR IP1 ;YES, MORE ITEMS.
|
| 801 |
+
IP5:
|
| 802 |
+
RST 30H
|
| 803 |
+
DEFLT:
|
| 804 |
+
LD A,(DE) ;*** DEFLT ***
|
| 805 |
+
CP CR ;EMPTY LINE IS OK
|
| 806 |
+
JR Z,LT1 ;ELSE IT IS 'LET'
|
| 807 |
+
LET:
|
| 808 |
+
CALL SETVAL ;*** LET ***
|
| 809 |
+
RST 08H ;SET VALUE TO VAR
|
| 810 |
+
DB ',' ;---DISASSEMBLE = INC L
|
| 811 |
+
DB LT1-$-1 ;---DISASSEMBLE = INC BC
|
| 812 |
+
JR LET ;ITEM BY ITEM
|
| 813 |
+
LT1:
|
| 814 |
+
RST 30H ;UNTIL FINISH
|
| 815 |
+
;*************************************************************
|
| 816 |
+
;
|
| 817 |
+
; *** EXPR ***
|
| 818 |
+
;
|
| 819 |
+
; 'EXPR' EVALUATES ARITHMETICAL OR LOGICAL EXPRESSIONS.
|
| 820 |
+
; <EXPR>::<EXPR2>
|
| 821 |
+
; <EXPR2><REL.OP.><EXPR2>
|
| 822 |
+
; WHERE <REL.OP.> IS ONE OF THE OPERATORS IN TAB8 AND THE
|
| 823 |
+
; RESULT OF THESE OPERATIONS IS 1 IF TRUE AND 0 IF FALSE.
|
| 824 |
+
; <EXPR2>::=(+ OR -)<EXPR3>(+ OR -<EXPR3>)(....)
|
| 825 |
+
; WHERE () ARE OPTIONAL AND (....) ARE OPTIONAL REPEATS.
|
| 826 |
+
; <EXPR3>::=<EXPR4>(* OR /><EXPR4>)(....)
|
| 827 |
+
; <EXPR4>::=<VARIABLE>
|
| 828 |
+
; <FUNCTION>
|
| 829 |
+
; (<EXPR>)
|
| 830 |
+
; <EXPR> IS RECURSIVE SO THAT VARIABLE '@' CAN HAVE AN <EXPR>
|
| 831 |
+
; AS INDEX, FUNCTIONS CAN HAVE AN <EXPR> AS ARGUMENTS, AND
|
| 832 |
+
; <EXPR4> CAN BE AN <EXPR> IN PARANTHESE.
|
| 833 |
+
;*************************************************************
|
| 834 |
+
|
| 835 |
+
EXPR1:
|
| 836 |
+
LD HL,TAB8-1 ;LOOKUP REL.OP.
|
| 837 |
+
JP EXEC ;GO DO IT
|
| 838 |
+
XP11:
|
| 839 |
+
CALL XP18 ;REL.OP.">="
|
| 840 |
+
RET C ;NO, RETURN HL=0
|
| 841 |
+
LD L,A ;YES, RETURN HL=1
|
| 842 |
+
RET
|
| 843 |
+
XP12:
|
| 844 |
+
CALL XP18 ;REL.OP."#"
|
| 845 |
+
RET Z ;FALSE, RETURN HL=0
|
| 846 |
+
LD L,A ;TRUE, RETURN HL=1
|
| 847 |
+
RET
|
| 848 |
+
XP13:
|
| 849 |
+
CALL XP18 ;REL.OP.">"
|
| 850 |
+
RET Z ;FALSE
|
| 851 |
+
RET C ;ALSO FALSE, HL=0
|
| 852 |
+
LD L,A ;TRUE, HL=1
|
| 853 |
+
RET
|
| 854 |
+
XP14:
|
| 855 |
+
CALL XP18 ;REL.OP."<="
|
| 856 |
+
LD L,A ;SET HL=1
|
| 857 |
+
RET Z ;REL. TRUE, RETURN
|
| 858 |
+
RET C
|
| 859 |
+
LD L,H ;ELSE SET HL=0
|
| 860 |
+
RET
|
| 861 |
+
XP15:
|
| 862 |
+
CALL XP18 ;REL.OP."="
|
| 863 |
+
RET NZ ;FALSE, RETURN HL=0
|
| 864 |
+
LD L,A ;ELSE SET HL=1
|
| 865 |
+
RET
|
| 866 |
+
XP16:
|
| 867 |
+
CALL XP18 ;REL.OP."<"
|
| 868 |
+
RET NC ;FALSE, RETURN HL=0
|
| 869 |
+
LD L,A ;ELSE SET HL=1
|
| 870 |
+
RET
|
| 871 |
+
XP17:
|
| 872 |
+
POP HL ;NOT .REL.OP
|
| 873 |
+
RET ;RETURN HL=<EXPR2>
|
| 874 |
+
XP18:
|
| 875 |
+
LD A,C ;SUBROUTINE FOR ALL
|
| 876 |
+
POP HL ;REL.OP.'S
|
| 877 |
+
POP BC
|
| 878 |
+
PUSH HL ;REVERSE TOP OF STACK
|
| 879 |
+
PUSH BC
|
| 880 |
+
LD C,A
|
| 881 |
+
CALL EXPR2 ;GET 2ND <EXPR2>
|
| 882 |
+
EX DE,HL ;VALUE IN DE NOW
|
| 883 |
+
EX (SP),HL ;1ST <EXPR2> IN HL
|
| 884 |
+
CALL CKHLDE ;COMPARE 1ST WITH 2ND
|
| 885 |
+
POP DE ;RESTORE TEXT POINTER
|
| 886 |
+
LD HL,0000H ;SET HL=0, A=1
|
| 887 |
+
LD A,01H
|
| 888 |
+
RET
|
| 889 |
+
EXPR2:
|
| 890 |
+
RST 08H ;NEGATIVE SIGN?
|
| 891 |
+
DB '-'
|
| 892 |
+
DB XP21-$-1
|
| 893 |
+
LD HL,0000H ;YES, FAKE '0-'
|
| 894 |
+
JR XP26 ;TREAT LIKE SUBTRACT
|
| 895 |
+
XP21:
|
| 896 |
+
RST 08H ;POSITIVE SIGN? IGNORE
|
| 897 |
+
DB '+'
|
| 898 |
+
DB XP22-$-1
|
| 899 |
+
XP22:
|
| 900 |
+
CALL EXPR3 ;1ST <EXPR3>
|
| 901 |
+
XP23:
|
| 902 |
+
RST 08H ;ADD?
|
| 903 |
+
DB '+'
|
| 904 |
+
DB XP25-$-1
|
| 905 |
+
PUSH HL ;YES, SAVE VALUE
|
| 906 |
+
CALL EXPR3 ;GET 2ND <EXPR3>
|
| 907 |
+
XP24:
|
| 908 |
+
EX DE,HL ;2ND IN DE
|
| 909 |
+
EX (SP),HL ;1ST IN HL
|
| 910 |
+
LD A,H ;COMPARE SIGN
|
| 911 |
+
XOR D
|
| 912 |
+
LD A,D
|
| 913 |
+
ADD HL,DE
|
| 914 |
+
POP DE ;RESTORE TEXT POINTER
|
| 915 |
+
JP M,XP23 ;1ST AND 2ND SIGN DIFFER
|
| 916 |
+
XOR H ;1ST AND 2ND SIGN EQUAL
|
| 917 |
+
JP P,XP23 ;SO IS RESULT
|
| 918 |
+
JP QHOW ;ELSE WE HAVE OVERFLOW
|
| 919 |
+
XP25:
|
| 920 |
+
RST 08H ;SUBTRACT?
|
| 921 |
+
DB '-'
|
| 922 |
+
DB XP42-$-1
|
| 923 |
+
XP26:
|
| 924 |
+
PUSH HL ;YES, SAVE 1ST <EXPR3>
|
| 925 |
+
CALL EXPR3 ;GET 2ND <EXPR3>
|
| 926 |
+
CALL CHGSGN ;NEGATE
|
| 927 |
+
JR XP24 ;AND ADD THEM
|
| 928 |
+
;
|
| 929 |
+
EXPR3:
|
| 930 |
+
CALL EXPR4 ;GET 1ST <EXPR4>
|
| 931 |
+
XP31:
|
| 932 |
+
RST 08H ;MULTIPLY?
|
| 933 |
+
DB '*'
|
| 934 |
+
DB XP34-$-1
|
| 935 |
+
PUSH HL ;YES, SAVE 1ST
|
| 936 |
+
CALL EXPR4 ;AND GET 2ND <EXPR4>
|
| 937 |
+
LD B,00H ;CLEAR B FOR SIGN
|
| 938 |
+
CALL CHKSGN ;CHECK SIGN
|
| 939 |
+
EX (SP),HL ;1ST IN HL
|
| 940 |
+
CALL CHKSGN ;CHECK SIGN OF 1ST
|
| 941 |
+
EX DE,HL
|
| 942 |
+
EX (SP),HL
|
| 943 |
+
LD A,H ;IS HL > 255 ?
|
| 944 |
+
OR A
|
| 945 |
+
JR Z,XP32 ;NO
|
| 946 |
+
LD A,D ;YES, HOW ABOUT DE
|
| 947 |
+
OR D
|
| 948 |
+
EX DE,HL ;PUT SMALLER IN HL
|
| 949 |
+
JP NZ,AHOW ;ALSO >, WILL OVERFLOW
|
| 950 |
+
XP32:
|
| 951 |
+
LD A,L ;THIS IS DUMB
|
| 952 |
+
LD HL,0000H ;CLEAR RESULT
|
| 953 |
+
OR A ;ADD AND COUNT
|
| 954 |
+
JR Z,XP35
|
| 955 |
+
XP33:
|
| 956 |
+
ADD HL,DE
|
| 957 |
+
JP C,AHOW ;OVERFLOW
|
| 958 |
+
DEC A
|
| 959 |
+
JR NZ,XP33
|
| 960 |
+
JR XP35 ;FINISHED
|
| 961 |
+
XP34:
|
| 962 |
+
RST 08H ;DIVIDE?
|
| 963 |
+
DB '/'
|
| 964 |
+
DB XP42-$-1
|
| 965 |
+
PUSH HL ;YES, SAVE 1ST <EXPR4>
|
| 966 |
+
CALL EXPR4 ;AND GET THE SECOND ONE
|
| 967 |
+
LD B,00H ;CLEAR B FOR SIGN
|
| 968 |
+
CALL CHKSGN ;CHECK SIGN OF 2ND
|
| 969 |
+
EX (SP),HL ;GET 1ST IN HL
|
| 970 |
+
CALL CHKSGN ;CHECK SIGN OF 1ST
|
| 971 |
+
EX DE,HL
|
| 972 |
+
EX (SP),HL
|
| 973 |
+
EX DE,HL
|
| 974 |
+
LD A,D ;DIVIDE BY 0?
|
| 975 |
+
OR E
|
| 976 |
+
JP Z,AHOW ;SAY "HOW?"
|
| 977 |
+
PUSH BC ;ELSE SAVE SIGN
|
| 978 |
+
CALL DIVIDE ;USE SUBROUTINE
|
| 979 |
+
LD H,B ;RESULT IN HL NOW
|
| 980 |
+
LD L,C
|
| 981 |
+
POP BC ;GET SIGN BACK
|
| 982 |
+
XP35:
|
| 983 |
+
POP DE ;AND TEXT POINTER
|
| 984 |
+
LD A,H ;HL MUST BE +
|
| 985 |
+
OR A
|
| 986 |
+
JP M,QHOW ;ELSE IT IS OVERFLOW
|
| 987 |
+
LD A,B
|
| 988 |
+
OR A
|
| 989 |
+
CALL M,CHGSGN ;CHANGE SIGN IF NEEDED
|
| 990 |
+
JR XP31 ;LOOK FOR MORE TERMS
|
| 991 |
+
EXPR4:
|
| 992 |
+
LD HL,TAB4-1 ;FIND FUNCTION IN TAB4
|
| 993 |
+
JP EXEC ;AND GO DO IT
|
| 994 |
+
XP40:
|
| 995 |
+
RST 38H ;NO, NOT A FUNCTION
|
| 996 |
+
JR C,XP41 ;NOR A VARIABLE
|
| 997 |
+
LD A,(HL) ;VARIABLE
|
| 998 |
+
INC HL
|
| 999 |
+
LD H,(HL) ;VALUE IN HL
|
| 1000 |
+
LD L,A
|
| 1001 |
+
RET
|
| 1002 |
+
XP41:
|
| 1003 |
+
CALL TSTNUM ;OR IS IT A NUMBER
|
| 1004 |
+
LD A,B ;# OF DIGIT
|
| 1005 |
+
OR A
|
| 1006 |
+
RET NZ ;OK
|
| 1007 |
+
PARN:
|
| 1008 |
+
RST 08H
|
| 1009 |
+
DB '('
|
| 1010 |
+
DB XP43-$-1
|
| 1011 |
+
RST 18H ;"(EXPR)"
|
| 1012 |
+
RST 08H
|
| 1013 |
+
DB ')'
|
| 1014 |
+
DB XP43-$-1
|
| 1015 |
+
XP42:
|
| 1016 |
+
RET
|
| 1017 |
+
XP43:
|
| 1018 |
+
JP QWHAT ;ELSE SAY: "WHAT?"
|
| 1019 |
+
RND:
|
| 1020 |
+
CALL PARN ;*** RND(EXPR) ***
|
| 1021 |
+
LD A,H ;EXPR MUST BE +
|
| 1022 |
+
OR A
|
| 1023 |
+
JP M,QHOW
|
| 1024 |
+
OR L ;AND NON-ZERO
|
| 1025 |
+
JP Z,QHOW
|
| 1026 |
+
PUSH DE ;SAVE BOTH
|
| 1027 |
+
PUSH HL
|
| 1028 |
+
LD HL,(RANPNT) ;GET MEMORY AS RANDOM
|
| 1029 |
+
LD DE,LSTROM ;NUMBER
|
| 1030 |
+
RST 20H
|
| 1031 |
+
JR C,RA1 ;WRAP AROUND IF LAST
|
| 1032 |
+
LD HL,START
|
| 1033 |
+
RA1:
|
| 1034 |
+
LD E,(HL)
|
| 1035 |
+
INC HL
|
| 1036 |
+
LD D,(HL)
|
| 1037 |
+
LD (RANPNT),HL
|
| 1038 |
+
POP HL
|
| 1039 |
+
EX DE,HL
|
| 1040 |
+
PUSH BC
|
| 1041 |
+
CALL DIVIDE ;RND (N)=MOD(M,N)+1
|
| 1042 |
+
POP BC
|
| 1043 |
+
POP DE
|
| 1044 |
+
INC HL
|
| 1045 |
+
RET
|
| 1046 |
+
ABS:
|
| 1047 |
+
CALL PARN ;*** ABS (EXPR) ***
|
| 1048 |
+
DEC DE
|
| 1049 |
+
CALL CHKSGN ;CHECK SIGN
|
| 1050 |
+
INC DE
|
| 1051 |
+
RET
|
| 1052 |
+
SIZE:
|
| 1053 |
+
LD HL,(TXTUNF) ;*** SIZE ***
|
| 1054 |
+
PUSH DE ;GET THE NUMBER OF FREE
|
| 1055 |
+
EX DE,HL ;BYTES BETWEEN 'TXTUNF'
|
| 1056 |
+
LD HL,VARBGN ;AND 'VARBGN'
|
| 1057 |
+
CALL SUBDE
|
| 1058 |
+
POP DE
|
| 1059 |
+
RET
|
| 1060 |
+
;*************************************************************
|
| 1061 |
+
;
|
| 1062 |
+
; *** DIVIDE *** SUBDE *** CHKSGN *** CHGSGN *** & CKHLDE ***
|
| 1063 |
+
;
|
| 1064 |
+
; 'DIVIDE' DIVIDES HL BY DE, RESULT IN BC, REMAINDER IN HL
|
| 1065 |
+
;
|
| 1066 |
+
; 'SUBDE' SUBSTRACTS DE FROM HL
|
| 1067 |
+
;
|
| 1068 |
+
; 'CHKSGN' CHECKS SIGN OF HL. IF +, NO CHANGE. IF -, CHANGE
|
| 1069 |
+
; SIGN AND FLIP SIGN OF B.
|
| 1070 |
+
;
|
| 1071 |
+
; 'CHGSGN' CHECKS SIGN N OF HL AND B UNCONDITIONALLY.
|
| 1072 |
+
;
|
| 1073 |
+
; 'CKHLDE' CHECKS SIGN OF HL AND DE. IF DIFFERENT, HL AND DE
|
| 1074 |
+
; ARE INTERCHANGED. IF SAME SIGN, NOT INTERCHANGED. EITHER
|
| 1075 |
+
; CASE, HL DE ARE THEN COMPARED TO SET THE FLAGS.
|
| 1076 |
+
;*************************************************************
|
| 1077 |
+
|
| 1078 |
+
DIVIDE:
|
| 1079 |
+
PUSH HL ;*** DIVIDE ***
|
| 1080 |
+
LD L,H ;DIVIDE H BY DE
|
| 1081 |
+
LD H,00H
|
| 1082 |
+
CALL DV1
|
| 1083 |
+
LD B,C ;SAVE RESULT IN B
|
| 1084 |
+
LD A,L ;(REMAINDER+L)/DE
|
| 1085 |
+
POP HL
|
| 1086 |
+
LD H,A
|
| 1087 |
+
DV1:
|
| 1088 |
+
LD C,0FFH ;RESULT IN C
|
| 1089 |
+
DV2:
|
| 1090 |
+
INC C ;DUMB ROUTINE
|
| 1091 |
+
CALL SUBDE ;DIVIDE BY SUBTRACT
|
| 1092 |
+
JR NC,DV2 ;AND COUNT
|
| 1093 |
+
ADD HL,DE
|
| 1094 |
+
RET
|
| 1095 |
+
SUBDE:
|
| 1096 |
+
LD A,L ;*** SUBDE ***
|
| 1097 |
+
SUB E ;SUBSTRACT DE FROM
|
| 1098 |
+
LD L,A ;HL
|
| 1099 |
+
LD A,H
|
| 1100 |
+
SBC A,D
|
| 1101 |
+
LD H,A
|
| 1102 |
+
RET
|
| 1103 |
+
CHKSGN:
|
| 1104 |
+
LD A,H ;*** CHKSGN ***
|
| 1105 |
+
OR A ;CHECK SIGN OF HL
|
| 1106 |
+
RET P
|
| 1107 |
+
CHGSGN:
|
| 1108 |
+
LD A,H ;*** CHGSGN ***
|
| 1109 |
+
PUSH AF
|
| 1110 |
+
CPL ;CHANGE SIGN OF HL
|
| 1111 |
+
LD H,A
|
| 1112 |
+
LD A,L
|
| 1113 |
+
CPL
|
| 1114 |
+
LD L,A
|
| 1115 |
+
INC HL
|
| 1116 |
+
POP AF
|
| 1117 |
+
XOR H
|
| 1118 |
+
JP P,QHOW
|
| 1119 |
+
LD A,B ;AND ALSO FLIP B
|
| 1120 |
+
XOR 80H
|
| 1121 |
+
LD B,A
|
| 1122 |
+
RET
|
| 1123 |
+
CKHLDE:
|
| 1124 |
+
LD A,H ;SAME SIGN?
|
| 1125 |
+
XOR D ;YES, COMPARE
|
| 1126 |
+
JP P,CK1 ;NO, XCHANGE AND COMP
|
| 1127 |
+
EX DE,HL
|
| 1128 |
+
CK1:
|
| 1129 |
+
RST 20H
|
| 1130 |
+
RET
|
| 1131 |
+
;*************************************************************
|
| 1132 |
+
;
|
| 1133 |
+
; *** SETVAL *** FIN *** ENDCHK *** & ERROR (& FRIENDS) ***
|
| 1134 |
+
;
|
| 1135 |
+
; "SETVAL" EXPECTS A VARIABLE, FOLLOWED BY AN EQUAL SIGN AND
|
| 1136 |
+
; THEN AN EXPR. IT EVALUATES THE EXPR. AND SET THE VARIABLE
|
| 1137 |
+
; TO THAT VALUE.
|
| 1138 |
+
;
|
| 1139 |
+
; "FIN" CHECKS THE END OF A COMMAND. IF IT ENDED WITH ";",
|
| 1140 |
+
; EXECUTION CONTINUES. IF IT ENDED WITH A CR, IT FINDS THE
|
| 1141 |
+
; NEXT LINE AND CONTINUE FROM THERE.
|
| 1142 |
+
;
|
| 1143 |
+
; "ENDCHK" CHECKS IF A COMMAND IS ENDED WITH CR. THIS IS
|
| 1144 |
+
; REQUIRED IN CERTAIN COMMANDS. (GOTO, RETURN, AND STOP ETC.)
|
| 1145 |
+
;
|
| 1146 |
+
; "ERROR" PRINTS THE STRING POINTED BY DE (AND ENDS WITH CR).
|
| 1147 |
+
; IT THEN PRINTS THE LINE POINTED BY 'CURRNT' WITH A "?"
|
| 1148 |
+
; INSERTED AT WHERE THE OLD TEXT POINTER (SHOULD BE ON TOP
|
| 1149 |
+
; OF THE STACK) POINTS TO. EXECUTION OF TB IS STOPPED
|
| 1150 |
+
; AND TBI IS RESTARTED. HOWEVER, IF 'CURRNT' -> ZERO
|
| 1151 |
+
; (INDICATING A DIRECT COMMAND), THE DIRECT COMMAND IS NOT
|
| 1152 |
+
; PRINTED. AND IF 'CURRNT' -> NEGATIVE # (INDICATING 'INPUT'
|
| 1153 |
+
; COMMAND), THE INPUT LINE IS NOT PRINTED AND EXECUTION IS
|
| 1154 |
+
; NOT TERMINATED BUT CONTINUED AT 'INPERR'.
|
| 1155 |
+
;
|
| 1156 |
+
; RELATED TO 'ERROR' ARE THE FOLLOWING:
|
| 1157 |
+
; 'QWHAT' SAVES TEXT POINTER IN STACK AND GET MESSAGE "WHAT?"
|
| 1158 |
+
; 'AWHAT' JUST GET MESSAGE "WHAT?" AND JUMP TO 'ERROR'.
|
| 1159 |
+
; 'QSORRY' AND 'ASORRY' DO SAME KIND OF THING.
|
| 1160 |
+
; 'AHOW' AND 'AHOW' IN THE ZERO PAGE SECTION ALSO DO THIS.
|
| 1161 |
+
;*************************************************************
|
| 1162 |
+
|
| 1163 |
+
SETVAL:
|
| 1164 |
+
RST 38H ;*** SETVAL ***
|
| 1165 |
+
JP C,QWHAT ;"WHAT?" NO VARIABLE
|
| 1166 |
+
PUSH HL ;SAVE ADDRESS OF VAR.
|
| 1167 |
+
RST 08H ;PASS "=" SIGN
|
| 1168 |
+
DB '='
|
| 1169 |
+
DB SV1-$-1
|
| 1170 |
+
RST 18H ;EVALUATE EXPR.
|
| 1171 |
+
LD B,H ;VALUE IS IN BC NOW
|
| 1172 |
+
LD C,L
|
| 1173 |
+
POP HL ;GET ADDRESS
|
| 1174 |
+
LD (HL),C ;SAVE VALUE
|
| 1175 |
+
INC HL
|
| 1176 |
+
LD (HL),B
|
| 1177 |
+
RET
|
| 1178 |
+
SV1:
|
| 1179 |
+
JP QWHAT ;NO "=" SIGN
|
| 1180 |
+
FIN:
|
| 1181 |
+
RST 08H ;*** FIN ***
|
| 1182 |
+
DB 3BH
|
| 1183 |
+
DB FI1-$-1
|
| 1184 |
+
POP AF ;";", PURGE RET. ADDR.
|
| 1185 |
+
JP RUNSML ;CONTINUE SAME LINE
|
| 1186 |
+
FI1:
|
| 1187 |
+
RST 08H ;NOT ";", IS IT CR?
|
| 1188 |
+
DB CR
|
| 1189 |
+
DB FI2-$-1
|
| 1190 |
+
POP AF ;YES, PURGE RET. ADDR.
|
| 1191 |
+
JP RUNNXL ;RUN NEXT LINE
|
| 1192 |
+
FI2:
|
| 1193 |
+
RET ;ELSE RETURN TO CALLER
|
| 1194 |
+
ENDCHK:
|
| 1195 |
+
RST 28H ;*** ENDCHK ***
|
| 1196 |
+
CP CR ;END WITH CR?
|
| 1197 |
+
RET Z ;OK, ELSE SAY: "WHAT?"
|
| 1198 |
+
QWHAT:
|
| 1199 |
+
PUSH DE ;*** QWHAT ***
|
| 1200 |
+
AWHAT:
|
| 1201 |
+
LD DE,WHAT ;*** AWHAT ***
|
| 1202 |
+
ERROR_ROUTINE:
|
| 1203 |
+
SUB A ;*** ERROR ***
|
| 1204 |
+
CALL PRTSTG ;PRINT 'WHAT?', 'HOW?'
|
| 1205 |
+
POP DE ;OR 'SORRY'
|
| 1206 |
+
LD A,(DE) ;SAVE THE CHARACTER
|
| 1207 |
+
PUSH AF ;AT WHERE OLD DE ->
|
| 1208 |
+
SUB A ;AND PUT A 0 THERE
|
| 1209 |
+
LD (DE),A
|
| 1210 |
+
LD HL,(CURRNT) ;GET CURRENT LINE #
|
| 1211 |
+
PUSH HL
|
| 1212 |
+
LD A,(HL) ;CHECK THE VALUE
|
| 1213 |
+
INC HL
|
| 1214 |
+
OR (HL)
|
| 1215 |
+
POP DE
|
| 1216 |
+
JP Z,RSTART ;IF ZERO, JUST RESTART
|
| 1217 |
+
LD A,(HL) ;IF NEGATIVE,
|
| 1218 |
+
OR A
|
| 1219 |
+
JP M,INPERR ;REDO INPUT
|
| 1220 |
+
CALL PRTLN ;ELSE PRINT THE LINE
|
| 1221 |
+
DEC DE ;UPTO WHERE THE 0 IS
|
| 1222 |
+
POP AF ;RESTORE THE CHARACTER
|
| 1223 |
+
LD (DE),A
|
| 1224 |
+
LD A,3FH ;PRINT A "?"
|
| 1225 |
+
RST 10H
|
| 1226 |
+
SUB A ;AND THE REST OF THE
|
| 1227 |
+
CALL PRTSTG ;LINE
|
| 1228 |
+
JP RSTART ;THEN RESTART
|
| 1229 |
+
QSORRY:
|
| 1230 |
+
PUSH DE ;*** QSORRY ***
|
| 1231 |
+
ASORRY:
|
| 1232 |
+
LD DE,SORRY ;*** ASORRY ***
|
| 1233 |
+
JR ERROR_ROUTINE
|
| 1234 |
+
;*************************************************************
|
| 1235 |
+
;
|
| 1236 |
+
; *** GETLN *** FNDLN (& FRIENDS) ***
|
| 1237 |
+
;
|
| 1238 |
+
; 'GETLN' READS A INPUT LINE INTO 'BUFFER'. IT FIRST PROMPT
|
| 1239 |
+
; THE CHARACTER IN A (GIVEN BY THE CALLER), THEN IT FILLS
|
| 1240 |
+
; THE BUFFER AND ECHOS. IT IGNORES LF'S AND NULLS, BUT STILL
|
| 1241 |
+
; ECHOS THEM BACK. RUB-OUT IS USED TO CAUSE IT TO DELETE
|
| 1242 |
+
; THE LAST CHARACTER (IF THERE IS ONE), AND ALT-MOD IS USED TO
|
| 1243 |
+
; CAUSE IT TO DELETE THE WHOLE LINE AND START IT ALL OVER.
|
| 1244 |
+
; CR SIGNALS THE END OF A LINE, AND CAUSE 'GETLN' TO RETURN.
|
| 1245 |
+
;
|
| 1246 |
+
; 'FNDLN' FINDS A LINE WITH A GIVEN LINE # (IN HL) IN THE
|
| 1247 |
+
; TEXT SAVE AREA. DE IS USED AS THE TEXT POINTER. IF THE
|
| 1248 |
+
; LINE IS FOUND, DE WILL POINT TO THE BEGINNING OF THAT LINE
|
| 1249 |
+
; (I.E., THE LOW BYTE OF THE LINE #), AND FLAGS ARE NC & Z.
|
| 1250 |
+
; IF THAT LINE IS NOT THERE AND A LINE WITH A HIGHER LINE #
|
| 1251 |
+
; IS FOUND, DE POINTS TO THERE AND FLAGS ARE NC & NZ. IF
|
| 1252 |
+
; WE REACHED THE END OF TEXT SAVE AREA AND CANNOT FIND THE
|
| 1253 |
+
; LINE, FLAGS ARE C & NZ.
|
| 1254 |
+
; 'FNDLN' WILL INITIALIZE DE TO THE BEGINNING OF THE TEXT SAVE
|
| 1255 |
+
; AREA TO START THE SEARCH. SOME OTHER ENTRIES OF THIS
|
| 1256 |
+
; ROUTINE WILL NOT INITIALIZE DE AND DO THE SEARCH.
|
| 1257 |
+
; 'FNDLNP' WILL START WITH DE AND SEARCH FOR THE LINE #.
|
| 1258 |
+
; 'FNDNXT' WILL BUMP DE BY 2, FIND A CR AND THEN START SEARCH.
|
| 1259 |
+
; 'FNDSKP' USE DE TO FIND A CR, AND THEN START SEARCH.
|
| 1260 |
+
;*************************************************************
|
| 1261 |
+
|
| 1262 |
+
GETLN:
|
| 1263 |
+
RST 10H ;*** GETLN ***
|
| 1264 |
+
LD DE,BUFFER ;PROMPT AND INIT.
|
| 1265 |
+
GL1:
|
| 1266 |
+
CALL CHKIO ;CHECK KEYBOARD
|
| 1267 |
+
JR Z,GL1 ;NO INPUT, WAIT
|
| 1268 |
+
CP 7FH ;DELETE LAST CHARACTER?
|
| 1269 |
+
JR Z,GL3 ;YES
|
| 1270 |
+
RST 10H ;INPUT, ECHO BACK
|
| 1271 |
+
CP 0AH ;IGNORE LF
|
| 1272 |
+
JR Z,GL1
|
| 1273 |
+
OR A ;IGNORE NULL
|
| 1274 |
+
JR Z,GL1
|
| 1275 |
+
CP 7DH ;DELETE THE WHOLE LINE?
|
| 1276 |
+
JR Z,GL4 ;YES
|
| 1277 |
+
LD (DE),A ;ELSE SAVE INPUT
|
| 1278 |
+
INC DE ;AND BUMP POINTER
|
| 1279 |
+
CP 0DH ;WAS IT CR
|
| 1280 |
+
RET Z ;YES, END OF LINE
|
| 1281 |
+
LD A,E ;ELSE MORE FREE ROOM?
|
| 1282 |
+
CP BUFEND & 0FFH
|
| 1283 |
+
JR NZ,GL1 ;YES, GET NEXT INPUT
|
| 1284 |
+
GL3:
|
| 1285 |
+
LD A,E ;DELETE LAST CHARACTER
|
| 1286 |
+
CP BUFFER & 0FFH ;BUT DO WE HAVE ANY?
|
| 1287 |
+
JR Z,GL4 ;NO, REDO WHOLE LINE
|
| 1288 |
+
DEC DE ;YES, BACKUP POINTER
|
| 1289 |
+
LD A,5CH ;AND ECHO A BACK-SLASH
|
| 1290 |
+
RST 10H
|
| 1291 |
+
JR GL1 ;GO GET NEXT INPUT
|
| 1292 |
+
GL4:
|
| 1293 |
+
CALL CRLF ;REDO ENTIRE LINE
|
| 1294 |
+
LD A,05EH ;CR, LF AND UP-ARROW
|
| 1295 |
+
JR GETLN
|
| 1296 |
+
FNDLN:
|
| 1297 |
+
LD A,H ;*** FNDLN ***
|
| 1298 |
+
OR A ;CHECK SIGN OF HL
|
| 1299 |
+
JP M,QHOW ;IT CANNOT BE -
|
| 1300 |
+
LD DE,TXTBGN ;INIT TEXT POINTER
|
| 1301 |
+
FNDLP: ;*** FDLNP ***
|
| 1302 |
+
FL1:
|
| 1303 |
+
PUSH HL ;SAVE LINE #
|
| 1304 |
+
LD HL,(TXTUNF) ;CHECK IF WE PASSED END
|
| 1305 |
+
DEC HL
|
| 1306 |
+
RST 20H
|
| 1307 |
+
POP HL ;GET LINE # BACK
|
| 1308 |
+
RET C ;C,NZ PASSED END
|
| 1309 |
+
LD A,(DE) ;WE DID NOT, GET BYTE 1
|
| 1310 |
+
SUB L ;IS THIS THE LINE?
|
| 1311 |
+
LD B,A ;COMPARE LOW ORDER
|
| 1312 |
+
INC DE
|
| 1313 |
+
LD A,(DE) ;GET BYTE 2
|
| 1314 |
+
SBC A,H ;COMPARE HIGH ORDER
|
| 1315 |
+
JR C,FL2 ;NO, NOT THERE YET
|
| 1316 |
+
DEC DE ;ELSE WE EITHER FOUND
|
| 1317 |
+
OR B ;IT, OR IT IS NOT THERE
|
| 1318 |
+
RET ;NC,Z;FOUND, NC,NZ:NO
|
| 1319 |
+
FNDNXT: ;*** FNDNXT ***
|
| 1320 |
+
INC DE ;FIND NEXT LINE
|
| 1321 |
+
FL2:
|
| 1322 |
+
INC DE ;JUST PASSED BYTE 1 & 2
|
| 1323 |
+
FNDSKP:
|
| 1324 |
+
LD A,(DE) ;*** FNDSKP ***
|
| 1325 |
+
CP CR ;TRY TO FIND CR
|
| 1326 |
+
JR NZ,FL2 ;KEEP LOOKING
|
| 1327 |
+
INC DE ;FOUND CR, SKIP OVER
|
| 1328 |
+
JR FL1 ;CHECK IF END OF TEXT
|
| 1329 |
+
;*************************************************************
|
| 1330 |
+
;
|
| 1331 |
+
; *** PRTSTG *** QTSTG *** PRTNUM *** & PRTLN ***
|
| 1332 |
+
;
|
| 1333 |
+
; 'PRTSTG' PRINTS A STRING POINTED BY DE. IT STOPS PRINTING
|
| 1334 |
+
; AND RETURNS TO CALLER WHEN EITHER A CR IS PRINTED OR WHEN
|
| 1335 |
+
; THE NEXT BYTE IS THE SAME AS WHAT WAS IN A (GIVEN BY THE
|
| 1336 |
+
; CALLER). OLD A IS STORED IN B, OLD B IS LOST.
|
| 1337 |
+
;
|
| 1338 |
+
; 'QTSTG' LOOKS FOR A BACK-ARROW, SINGLE QUOTE, OR DOUBLE
|
| 1339 |
+
; QUOTE. IF NONE OF THESE, RETURN TO CALLER. IF BACK-ARROW,
|
| 1340 |
+
; OUTPUT A CR WITHOUT A LF. IF SINGLE OR DOUBLE QUOTE, PRINT
|
| 1341 |
+
; THE STRING IN THE QUOTE AND DEMANDS A MATCHING UNQUOTE.
|
| 1342 |
+
; AFTER THE PRINTING THE NEXT 3 BYTES OF THE CALLER IS SKIPPED
|
| 1343 |
+
; OVER (USUALLY A JUMP INSTRUCTION.
|
| 1344 |
+
;
|
| 1345 |
+
; 'PRTNUM' PRINTS THE NUMBER IN HL. LEADING BLANKS ARE ADDED
|
| 1346 |
+
; IF NEEDED TO PAD THE NUMBER OF SPACES TO THE NUMBER IN C.
|
| 1347 |
+
; HOWEVER, IF THE NUMBER OF DIGITS IS LARGER THAN THE # IN
|
| 1348 |
+
; C, ALL DIGITS ARE PRINTED ANYWAY. NEGATIVE SIGN IS ALSO
|
| 1349 |
+
; PRINTED AND COUNTED IN, POSITIVE SIGN IS NOT.
|
| 1350 |
+
;
|
| 1351 |
+
; 'PRTLN' PRINTS A SAVED TEXT LINE WITH LINE # AND ALL.
|
| 1352 |
+
;*************************************************************
|
| 1353 |
+
|
| 1354 |
+
PRTSTG:
|
| 1355 |
+
LD B,A ;*** PRTSTG ***
|
| 1356 |
+
PS1:
|
| 1357 |
+
LD A,(DE) ;GET A CHARACTER
|
| 1358 |
+
INC DE ;BUMP POINTER
|
| 1359 |
+
CP B ;SAME AS OLD A?
|
| 1360 |
+
RET Z ;YES, RETURN
|
| 1361 |
+
RST 10H ;NO, NEXT
|
| 1362 |
+
CP CR ;WAS IT A CR?
|
| 1363 |
+
JR NZ,PS1 ;NO, NEXT
|
| 1364 |
+
RET ;YES, RETURN
|
| 1365 |
+
QTSTG:
|
| 1366 |
+
RST 08H ;*** QTSTG ***
|
| 1367 |
+
DB '"'
|
| 1368 |
+
DB QT3-$-1
|
| 1369 |
+
LD A,22H ;IT IS A "
|
| 1370 |
+
QT1:
|
| 1371 |
+
CALL PRTSTG ;PRINT UNTIL ANOTHER
|
| 1372 |
+
CP CR ;WAS LAST ONE A CR?
|
| 1373 |
+
POP HL ;RETURN ADDRESS
|
| 1374 |
+
JP Z,RUNNXL ;WAS CR, RUN NEXT LINE
|
| 1375 |
+
QT2:
|
| 1376 |
+
INC HL ;SKIP 3 BYTES ON RETURN
|
| 1377 |
+
INC HL
|
| 1378 |
+
INC HL
|
| 1379 |
+
JP (HL) ;RETURN
|
| 1380 |
+
QT3:
|
| 1381 |
+
RST 08H ;IS IT A '?
|
| 1382 |
+
DB 27H
|
| 1383 |
+
DB QT4-$-1
|
| 1384 |
+
LD A,27H ;YES, DO THE SAME
|
| 1385 |
+
JR QT1 ;AS IN "
|
| 1386 |
+
QT4:
|
| 1387 |
+
RST 08H ;IS IT BACK-ARROW?
|
| 1388 |
+
DB 5FH
|
| 1389 |
+
DB QT5-$-1
|
| 1390 |
+
LD A,8DH ;YES, CR WITHOUT LF
|
| 1391 |
+
RST 10H ;DO IT TWICE TO GIVE
|
| 1392 |
+
RST 10H ;TTY ENOUGH TIME
|
| 1393 |
+
POP HL ;RETURN ADDRESS
|
| 1394 |
+
JR QT2
|
| 1395 |
+
QT5:
|
| 1396 |
+
RET ;NONE OF ABOVE
|
| 1397 |
+
;
|
| 1398 |
+
PRTNUM:
|
| 1399 |
+
LD B,00H ;*** PRTNUM ***
|
| 1400 |
+
CALL CHKSGN ;CHECK SIGN
|
| 1401 |
+
JP P,PN1 ;NO SIGN
|
| 1402 |
+
LD B,'-' ;B=SIGN
|
| 1403 |
+
DEC C ;'-' TAKES SPACE
|
| 1404 |
+
PN1:
|
| 1405 |
+
PUSH DE ;SAVE
|
| 1406 |
+
LD DE,000AH ;DECIMAL
|
| 1407 |
+
PUSH DE ;SAVE AS FLAG
|
| 1408 |
+
DEC C ;C=SPACES
|
| 1409 |
+
PUSH BC ;SAVE SIGN & SPACE
|
| 1410 |
+
PN2:
|
| 1411 |
+
CALL DIVIDE ;DIVIDE HL BY 10
|
| 1412 |
+
LD A,B ;RESULT 0?
|
| 1413 |
+
OR C
|
| 1414 |
+
JR Z,PN3 ;YES, WE GOT ALL
|
| 1415 |
+
EX (SP),HL ;NO, SAVE REMAINDER
|
| 1416 |
+
DEC L ;AND COUNT SPACE
|
| 1417 |
+
PUSH HL ;HL IS OLD BC
|
| 1418 |
+
LD H,B ;MOVE RESULT TO BC
|
| 1419 |
+
LD L,C
|
| 1420 |
+
JR PN2 ;AND DIVIDE BY 10
|
| 1421 |
+
PN3:
|
| 1422 |
+
POP BC ;WE GOT ALL DIGITS IN
|
| 1423 |
+
PN4:
|
| 1424 |
+
DEC C ;THE STACK
|
| 1425 |
+
LD A,C ;LOOK AT SPACE COUNT
|
| 1426 |
+
OR A
|
| 1427 |
+
JP M,PN5 ;NO LEADING BLANKS
|
| 1428 |
+
LD A,20H ;LEADING BLANKS
|
| 1429 |
+
RST 10H
|
| 1430 |
+
JR PN4 ;MORE?
|
| 1431 |
+
PN5:
|
| 1432 |
+
LD A,B ;PRINT SIGN
|
| 1433 |
+
OR A
|
| 1434 |
+
CALL NZ,0010H
|
| 1435 |
+
LD E,L ;LAST REMAINDER IN E
|
| 1436 |
+
PN6:
|
| 1437 |
+
LD A,E ;CHECK DIGIT IN E
|
| 1438 |
+
CP 0AH ;10 IS FLAG FOR NO MORE
|
| 1439 |
+
POP DE
|
| 1440 |
+
RET Z ;IF SO, RETURN
|
| 1441 |
+
ADD A,30H ;ELSE, CONVERT TO ASCII
|
| 1442 |
+
RST 10H ;PRINT THE DIGIT
|
| 1443 |
+
JR PN6 ;GO BACK FOR MORE
|
| 1444 |
+
PRTLN:
|
| 1445 |
+
LD A,(DE) ;*** PRTLN ***
|
| 1446 |
+
LD L,A ;LOW ORDER LINE #
|
| 1447 |
+
INC DE
|
| 1448 |
+
LD A,(DE) ;HIGH ORDER
|
| 1449 |
+
LD H,A
|
| 1450 |
+
INC DE
|
| 1451 |
+
LD C,04H ;PRINT 4 DIGIT LINE #
|
| 1452 |
+
CALL PRTNUM
|
| 1453 |
+
LD A,20H ;FOLLOWED BY A BLANK
|
| 1454 |
+
RST 10H
|
| 1455 |
+
SUB A ;AND THEN THE NEXT
|
| 1456 |
+
CALL PRTSTG
|
| 1457 |
+
RET
|
| 1458 |
+
;*************************************************************
|
| 1459 |
+
;
|
| 1460 |
+
; *** MVUP *** MVDOWN *** POPA *** & PUSHA ***
|
| 1461 |
+
;
|
| 1462 |
+
; 'MVUP' MOVES A BLOCK UP FROM WHERE DE-> TO WHERE BC-> UNTIL
|
| 1463 |
+
; DE = HL
|
| 1464 |
+
;
|
| 1465 |
+
; 'MVDOWN' MOVES A BLOCK DOWN FROM WHERE DE-> TO WHERE HL->
|
| 1466 |
+
; UNTIL DE = BC
|
| 1467 |
+
;
|
| 1468 |
+
; 'POPA' RESTORES THE 'FOR' LOOP VARIABLE SAVE AREA FROM THE
|
| 1469 |
+
; STACK
|
| 1470 |
+
;
|
| 1471 |
+
; 'PUSHA' STACKS THE 'FOR' LOOP VARIABLE SAVE AREA INTO THE
|
| 1472 |
+
; STACK
|
| 1473 |
+
;*************************************************************
|
| 1474 |
+
|
| 1475 |
+
MVUP:
|
| 1476 |
+
RST 20H ;*** MVUP ***
|
| 1477 |
+
RET Z ;DE = HL, RETURN
|
| 1478 |
+
LD A,(DE) ;GET ONE BYTE
|
| 1479 |
+
LD (BC),A ;MOVE IT
|
| 1480 |
+
INC DE ;INCREASE BOTH POINTERS
|
| 1481 |
+
INC BC
|
| 1482 |
+
JR MVUP ;UNTIL DONE
|
| 1483 |
+
MVDOWN:
|
| 1484 |
+
LD A,B ;*** MVDOWN ***
|
| 1485 |
+
SUB D ;TEST IF DE = BC
|
| 1486 |
+
JP NZ,MD1 ;NO, GO MOVE
|
| 1487 |
+
LD A,C ;MAYBE, OTHER BYTE?
|
| 1488 |
+
SUB E
|
| 1489 |
+
RET Z ;YES, RETURN
|
| 1490 |
+
MD1:
|
| 1491 |
+
DEC DE ;ELSE MOVE A BYTE
|
| 1492 |
+
DEC HL ;BUT FIRST DECREASE
|
| 1493 |
+
LD A,(DE) ;BOTH POINTERS AND
|
| 1494 |
+
LD (HL),A ;THEN DO IT
|
| 1495 |
+
JR MVDOWN ;LOOP BACK
|
| 1496 |
+
POPA:
|
| 1497 |
+
POP BC ;BC = RETURN ADDR.
|
| 1498 |
+
POP HL ;RESTORE LOPVAR, BUT
|
| 1499 |
+
LD (LOPVAR),HL ;=0 MEANS NO MORE
|
| 1500 |
+
LD A,H
|
| 1501 |
+
OR L
|
| 1502 |
+
JR Z,PP1 ;YEP, GO RETURN
|
| 1503 |
+
POP HL ;NOP, RESTORE OTHERS
|
| 1504 |
+
LD (LOPINC),HL
|
| 1505 |
+
POP HL
|
| 1506 |
+
LD (LOPLMT),HL
|
| 1507 |
+
POP HL
|
| 1508 |
+
LD (LOPLN),HL
|
| 1509 |
+
POP HL
|
| 1510 |
+
LD (LOPPT),HL
|
| 1511 |
+
PP1:
|
| 1512 |
+
PUSH BC ;BC = RETURN ADDR.
|
| 1513 |
+
RET
|
| 1514 |
+
PUSHA:
|
| 1515 |
+
LD HL,STKLMT ;*** PUSHA ***
|
| 1516 |
+
CALL CHGSGN
|
| 1517 |
+
POP BC ;BC=RETURN ADDRESS
|
| 1518 |
+
ADD HL,SP ;IS STACK NEAR THE TOP?
|
| 1519 |
+
JP NC,QSORRY ;YES, SORRY FOR THAT
|
| 1520 |
+
LD HL,(LOPVAR) ;ELSE SAVE LOOP VAR'S
|
| 1521 |
+
LD A,H ;BUT IF LOPVAR IS 0
|
| 1522 |
+
OR L ;THAT WILL BE ALL
|
| 1523 |
+
JR Z,PU1
|
| 1524 |
+
LD HL,(LOPPT) ;ELSE, MORE TO SAVE
|
| 1525 |
+
PUSH HL
|
| 1526 |
+
LD HL,(LOPLN)
|
| 1527 |
+
PUSH HL
|
| 1528 |
+
LD HL,(LOPLMT)
|
| 1529 |
+
PUSH HL
|
| 1530 |
+
LD HL,(LOPINC)
|
| 1531 |
+
PUSH HL
|
| 1532 |
+
LD HL,(LOPVAR)
|
| 1533 |
+
PU1:
|
| 1534 |
+
PUSH HL
|
| 1535 |
+
PUSH BC ;BC = RETURN ADDR.
|
| 1536 |
+
RET
|
| 1537 |
+
;*************************************************************
|
| 1538 |
+
;
|
| 1539 |
+
; *** OUTC *** & CHKIO ***
|
| 1540 |
+
;
|
| 1541 |
+
; THESE ARE THE ONLY I/O ROUTINES IN TBI.
|
| 1542 |
+
; 'OUTC' IS CONTROLLED BY A SOFTWARE SWITCH 'OCSW'. IF OCSW=0
|
| 1543 |
+
; 'OUTC' WILL JUST RETURN TO THE CALLER. IF OCSW IS NOT 0,
|
| 1544 |
+
; IT WILL OUTPUT THE BYTE IN A. IF THAT IS A CR, A LF IS ALSO
|
| 1545 |
+
; SEND OUT. ONLY THE FLAGS MAY BE CHANGED AT RETURN. ALL REG.
|
| 1546 |
+
; ARE RESTORED.
|
| 1547 |
+
;
|
| 1548 |
+
; 'CHKIO' CHECKS THE INPUT. IF NO INPUT, IT WILL RETURN TO
|
| 1549 |
+
; THE CALLER WITH THE Z FLAG SET. IF THERE IS INPUT, Z FLAG
|
| 1550 |
+
; IS CLEARED AND THE INPUT BYTE IS IN A. HOWEVER, IF THE
|
| 1551 |
+
; INPUT IS A CONTROL-O, THE 'OCSW' SWITCH IS COMPLIMENTED, AND
|
| 1552 |
+
; Z FLAG IS RETURNED. IF A CONTROL-C IS READ, 'CHKIO' WILL
|
| 1553 |
+
; RESTART TBI AND DO NOT RETURN TO THE CALLER.
|
| 1554 |
+
;
|
| 1555 |
+
; Do not modify these routines. Routines requiring
|
| 1556 |
+
; modification are : SERIAL_INIT, RX_RDY, and TX_RDY.
|
| 1557 |
+
;*************************************************************
|
| 1558 |
+
|
| 1559 |
+
INIT:
|
| 1560 |
+
DI
|
| 1561 |
+
CALL SERIAL_INIT ;INITIALIZE THE SIO
|
| 1562 |
+
LD D,19H
|
| 1563 |
+
PATLOP:
|
| 1564 |
+
CALL CRLF
|
| 1565 |
+
DEC D
|
| 1566 |
+
JR NZ,PATLOP
|
| 1567 |
+
SUB A
|
| 1568 |
+
LD DE,MSG1 ;PRINT THE BOOT MESSAGES
|
| 1569 |
+
CALL PRTSTG
|
| 1570 |
+
LD DE,MSG2
|
| 1571 |
+
CALL PRTSTG
|
| 1572 |
+
LD HL,START
|
| 1573 |
+
LD (RANPNT),HL
|
| 1574 |
+
LD HL,TXTBGN
|
| 1575 |
+
LD (TXTUNF),HL
|
| 1576 |
+
JP RSTART
|
| 1577 |
+
OUTC:
|
| 1578 |
+
JR NZ,OUTC2 ;IT IS ON
|
| 1579 |
+
POP AF ;IT IS OFF
|
| 1580 |
+
RET ;RESTORE AF AND RETURN
|
| 1581 |
+
OUTC2:
|
| 1582 |
+
CALL TX_RDY ;SEE IF TRANSMIT IS AVAILABLE
|
| 1583 |
+
POP AF ;RESTORE THE REGISTER
|
| 1584 |
+
OUT (SerialPort),A ;SEND THE BYTE
|
| 1585 |
+
CP CR
|
| 1586 |
+
RET NZ
|
| 1587 |
+
LD A,LF
|
| 1588 |
+
RST 10H
|
| 1589 |
+
LD A,CR
|
| 1590 |
+
RET
|
| 1591 |
+
CHKIO:
|
| 1592 |
+
CALL RX_RDY ;CHECK IF CHARACTER AVAILABLE
|
| 1593 |
+
RET Z ;RETURN IF NO CHARACTER AVAILABLE
|
| 1594 |
+
|
| 1595 |
+
PUSH BC ;IF IT'S A LF, IGNORE AND RETURN
|
| 1596 |
+
LD B,A ; AS IF THERE WAS NO CHARACTER.
|
| 1597 |
+
SUB LF
|
| 1598 |
+
JR Z,CHKIO2
|
| 1599 |
+
LD A,B ;OTHERWISE RESTORE 'A' AND 'BC'
|
| 1600 |
+
POP BC ; AND CONTINUE ON.
|
| 1601 |
+
|
| 1602 |
+
CP 0FH ;IS IT CONTROL-0?
|
| 1603 |
+
JR NZ,CI1 ;NO, MORE CHECKING
|
| 1604 |
+
LD A,(OCSW) ;CONTROL-0 FLIPS OCSW
|
| 1605 |
+
CPL ;ON TO OFF, OFF TO ON
|
| 1606 |
+
LD (OCSW),A
|
| 1607 |
+
JR CHKIO ;GET ANOTHER INPUT
|
| 1608 |
+
CHKIO2:
|
| 1609 |
+
LD A,00H ;CLEAR A
|
| 1610 |
+
OR A ;ZET THE Z-FLAG
|
| 1611 |
+
POP BC ;RESTORE THE 'BC' PAIR
|
| 1612 |
+
RET ;RETURN WITH 'Z' SET.
|
| 1613 |
+
CI1:
|
| 1614 |
+
CP 03H ;IS IT CONTROL-C?
|
| 1615 |
+
RET NZ ;NO, RETURN "NZ"
|
| 1616 |
+
JP RSTART ;YES, RESTART TBI
|
| 1617 |
+
|
| 1618 |
+
|
| 1619 |
+
MSG1: DB ESC,"[2J",ESC,"[H" ;SCREEN CLEAR
|
| 1620 |
+
DB 'Z80 TINY BASIC 2.0g',CR ;BOOT MESSAGE
|
| 1621 |
+
MSG2: DB 'PORTED BY DOUG GABBARD, 2017',CR
|
| 1622 |
+
|
| 1623 |
+
;*************************************************************
|
| 1624 |
+
;
|
| 1625 |
+
; *** TABLES *** DIRECT *** & EXEC ***
|
| 1626 |
+
;
|
| 1627 |
+
; THIS SECTION OF THE CODE TESTS A STRING AGAINST A TABLE.
|
| 1628 |
+
; WHEN A MATCH IS FOUND, CONTROL IS TRANSFERED TO THE SECTION
|
| 1629 |
+
; OF CODE ACCORDING TO THE TABLE.
|
| 1630 |
+
;
|
| 1631 |
+
; AT 'EXEC', DE SHOULD POINT TO THE STRING AND HL SHOULD POINT
|
| 1632 |
+
; TO THE TABLE-1. AT 'DIRECT', DE SHOULD POINT TO THE STRING.
|
| 1633 |
+
; HL WILL BE SET UP TO POINT TO TAB1-1, WHICH IS THE TABLE OF
|
| 1634 |
+
; ALL DIRECT AND STATEMENT COMMANDS.
|
| 1635 |
+
;
|
| 1636 |
+
; A '.' IN THE STRING WILL TERMINATE THE TEST AND THE PARTIAL
|
| 1637 |
+
; MATCH WILL BE CONSIDERED AS A MATCH. E.G., 'P.', 'PR.',
|
| 1638 |
+
; 'PRI.', 'PRIN.', OR 'PRINT' WILL ALL MATCH 'PRINT'.
|
| 1639 |
+
;
|
| 1640 |
+
; THE TABLE CONSISTS OF ANY NUMBER OF ITEMS. EACH ITEM
|
| 1641 |
+
; IS A STRING OF CHARACTERS WITH BIT 7 SET TO 0 AND
|
| 1642 |
+
; A JUMP ADDRESS STORED HI-LOW WITH BIT 7 OF THE HIGH
|
| 1643 |
+
; BYTE SET TO 1.
|
| 1644 |
+
;
|
| 1645 |
+
; END OF TABLE IS AN ITEM WITH A JUMP ADDRESS ONLY. IF THE
|
| 1646 |
+
; STRING DOES NOT MATCH ANY OF THE OTHER ITEMS, IT WILL
|
| 1647 |
+
; MATCH THIS NULL ITEM AS DEFAULT.
|
| 1648 |
+
;*************************************************************
|
| 1649 |
+
|
| 1650 |
+
TAB1: ;DIRECT COMMANDS
|
| 1651 |
+
DB 'LIST'
|
| 1652 |
+
DWA LIST
|
| 1653 |
+
DB 'RUN'
|
| 1654 |
+
DWA RUN
|
| 1655 |
+
DB 'NEW'
|
| 1656 |
+
DWA NEW
|
| 1657 |
+
TAB2: ;DIRECT/STATEMENT
|
| 1658 |
+
DB 'NEXT'
|
| 1659 |
+
DWA NEXT
|
| 1660 |
+
DB 'LET'
|
| 1661 |
+
DWA LET
|
| 1662 |
+
DB 'IF'
|
| 1663 |
+
DWA IFF
|
| 1664 |
+
DB 'GOTO'
|
| 1665 |
+
DWA GOTO
|
| 1666 |
+
DB 'GOSUB'
|
| 1667 |
+
DWA GOSUB
|
| 1668 |
+
DB 'RETURN'
|
| 1669 |
+
DWA RETURN
|
| 1670 |
+
DB 'REM'
|
| 1671 |
+
DWA REM
|
| 1672 |
+
DB 'FOR'
|
| 1673 |
+
DWA FOR
|
| 1674 |
+
DB 'INPUT'
|
| 1675 |
+
DWA INPUT
|
| 1676 |
+
DB 'PRINT'
|
| 1677 |
+
DWA PRINT
|
| 1678 |
+
DB 'STOP'
|
| 1679 |
+
DWA STOP
|
| 1680 |
+
DWA DEFLT
|
| 1681 |
+
TAB4: ;FUNCTIONS
|
| 1682 |
+
DB 'RND'
|
| 1683 |
+
DWA RND
|
| 1684 |
+
DB 'ABS'
|
| 1685 |
+
DWA ABS
|
| 1686 |
+
DB 'SIZE'
|
| 1687 |
+
DWA SIZE
|
| 1688 |
+
DWA XP40
|
| 1689 |
+
TAB5: ;"TO" IN "FOR"
|
| 1690 |
+
DB 'TO'
|
| 1691 |
+
DWA FR1
|
| 1692 |
+
DWA QWHAT
|
| 1693 |
+
TAB6: ;"STEP" IN "FOR"
|
| 1694 |
+
DB 'STEP'
|
| 1695 |
+
DWA FR2
|
| 1696 |
+
DWA FR3
|
| 1697 |
+
TAB8: ;RELATION OPERATORS
|
| 1698 |
+
DB '>='
|
| 1699 |
+
DWA XP11
|
| 1700 |
+
DB '#'
|
| 1701 |
+
DWA XP12
|
| 1702 |
+
DB '>'
|
| 1703 |
+
DWA XP13
|
| 1704 |
+
DB '='
|
| 1705 |
+
DWA XP15
|
| 1706 |
+
DB '<='
|
| 1707 |
+
DWA XP14
|
| 1708 |
+
DB '<'
|
| 1709 |
+
DWA XP16
|
| 1710 |
+
DWA XP17
|
| 1711 |
+
DIRECT: LD HL,TAB1-1 ;*** DIRECT ***
|
| 1712 |
+
EXEC: ;*** EXEC ***
|
| 1713 |
+
EX0: RST 28H ;IGNORE LEADING BLANKS
|
| 1714 |
+
PUSH DE ;SAVE POINTER
|
| 1715 |
+
EX1:
|
| 1716 |
+
LD A,(DE) ;IF FOUND '.' IN STRING
|
| 1717 |
+
INC DE ;BEFORE ANY MISMATCH
|
| 1718 |
+
CP 23H ;WE DECLARE A MATCH
|
| 1719 |
+
JR Z,EX3
|
| 1720 |
+
INC HL ;HL->TABLE
|
| 1721 |
+
CP (HL) ;IF MATCH, TEST NEXT
|
| 1722 |
+
JR Z,EX1
|
| 1723 |
+
LD A,7FH ;ELSE SEE IF BIT 7
|
| 1724 |
+
DEC DE ;OF TABLE IS SET, WHICH
|
| 1725 |
+
CP (HL) ;IS THE JUMP ADDR. (HI)
|
| 1726 |
+
JR C,EX5 ;C:YES, MATCHED
|
| 1727 |
+
EX2:
|
| 1728 |
+
INC HL ;NC:NO, FIND JUMP ADDR.
|
| 1729 |
+
CP (HL)
|
| 1730 |
+
JR NC,EX2
|
| 1731 |
+
INC HL ;BUMP TO NEXT TAB. ITEM
|
| 1732 |
+
POP DE ;RESTORE STRING POINTER
|
| 1733 |
+
JR EX0 ;TEST AGAINST NEXT ITEM
|
| 1734 |
+
EX3:
|
| 1735 |
+
LD A,7FH ;PARTIAL MATCH, FIND
|
| 1736 |
+
EX4:
|
| 1737 |
+
INC HL ;JUMP ADDR., WHICH IS
|
| 1738 |
+
CP (HL) ;FLAGGED BY BIT 7
|
| 1739 |
+
JR NC,EX4
|
| 1740 |
+
EX5:
|
| 1741 |
+
LD A,(HL) ;LOAD HL WITH THE JUMP
|
| 1742 |
+
INC HL ;ADDRESS FROM THE TABLE
|
| 1743 |
+
LD L,(HL)
|
| 1744 |
+
AND 7FH ;MASK OFF BIT 7
|
| 1745 |
+
LD H,A
|
| 1746 |
+
POP AF ;CLEAN UP THE GABAGE
|
| 1747 |
+
JP (HL) ;AND WE GO DO IT
|
| 1748 |
+
;-------------------------------------------------------------------------------
|
| 1749 |
+
;///////////////////////////////////////////////////////////////////////////////
|
| 1750 |
+
;-------------------------------------------------------------------------------
|
| 1751 |
+
;COMPUTER SPECIFIC ROUTINES.
|
| 1752 |
+
;-------------------------------------------------------------------------------
|
| 1753 |
+
SERIAL_INIT:
|
| 1754 |
+
|
| 1755 |
+
; This routine is for initializing your serial port.
|
| 1756 |
+
|
| 1757 |
+
RET
|
| 1758 |
+
;-------------------------------------------------------------------------------
|
| 1759 |
+
TX_RDY:
|
| 1760 |
+
; This routine is checking if the Serial Port is ready to send
|
| 1761 |
+
; a character.
|
| 1762 |
+
IN A,(0F1h)
|
| 1763 |
+
AND 1
|
| 1764 |
+
JP NZ,TX_RDY
|
| 1765 |
+
RET
|
| 1766 |
+
|
| 1767 |
+
;-------------------------------------------------------------------------------
|
| 1768 |
+
RX_RDY:
|
| 1769 |
+
|
| 1770 |
+
; This routine is for checking if a character is available over
|
| 1771 |
+
; serial. If a character is available, it returns to the calling
|
| 1772 |
+
; function with the character in 'A' and the Z-flag reset.
|
| 1773 |
+
; However, if a character is not available, it returns with the
|
| 1774 |
+
; Z-flag set.
|
| 1775 |
+
|
| 1776 |
+
RET
|
| 1777 |
+
;-------------------------------------------------------------------------------
|
| 1778 |
+
;///////////////////////////////////////////////////////////////////////////////
|
| 1779 |
+
;-------------------------------------------------------------------------------
|
| 1780 |
+
|
| 1781 |
+
LSTROM: ;ALL ABOVE CAN BE ROM
|
| 1782 |
+
;HERE DOWN MUST BE RAM
|
| 1783 |
+
ORG 08000H
|
| 1784 |
+
ORG 08700H ; Last 256 bytes of RAM
|
| 1785 |
+
VARBGN: DS 55 ;VARIABLE @(0)
|
| 1786 |
+
BUFFER: DS 64 ;INPUT BUFFER
|
| 1787 |
+
BUFEND: DS 1 ;BUFFER ENDS
|
| 1788 |
+
STKLMT: DS 1 ;TOP LIMIT FOR STACK
|
| 1789 |
+
END
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/asm/z80/tiny_basic_instructions.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:eff9ce157dc687d0a18436378ea757383a5ae8494e3dfda058100a39fca8ea20
|
| 3 |
+
size 775161
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/clean-builds.sh
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Clean all target build folders in $CORES and the log
|
| 3 |
+
|
| 4 |
+
if [[ -z "$JTFRAME" || -z "$JTROOT" || -z "$CORES" ]]; then exit 1; fi
|
| 5 |
+
|
| 6 |
+
TARGETS=`find $JTFRAME/target -maxdepth 1 -type d | tail -n +2 | xargs -l basename`
|
| 7 |
+
|
| 8 |
+
for i in $TARGETS; do
|
| 9 |
+
find $CORES -maxdepth 2 -type d -name $i | xargs rm -rf
|
| 10 |
+
rm -rf $JTROOT/log
|
| 11 |
+
done
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/conv.m
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Converts logo128.png to a 1-bit hex file
|
| 2 |
+
# to be used with osd.v
|
| 3 |
+
|
| 4 |
+
I=imread("logo128.png");
|
| 5 |
+
[r c] = size(I);
|
| 6 |
+
# bit conversion
|
| 7 |
+
f=fopen("osdback.hex","w");
|
| 8 |
+
f2=fopen("osdback.v","w")
|
| 9 |
+
fprintf(f2,"initial begin\n")
|
| 10 |
+
global cnt
|
| 11 |
+
cnt=0
|
| 12 |
+
for j=1:8:r/2
|
| 13 |
+
# fill to make width = 256
|
| 14 |
+
for k=c+1:256
|
| 15 |
+
fprintf(f,"0\n")
|
| 16 |
+
dump(f2,0)
|
| 17 |
+
endfor
|
| 18 |
+
for k=1:c
|
| 19 |
+
val=0;
|
| 20 |
+
for b=0:7
|
| 21 |
+
if I( (j+b)*2,k)!=0
|
| 22 |
+
printf("*")
|
| 23 |
+
val=bitset(val,b+1);
|
| 24 |
+
else
|
| 25 |
+
printf(" ")
|
| 26 |
+
endif
|
| 27 |
+
endfor
|
| 28 |
+
fprintf(f,"%X\n",val)
|
| 29 |
+
dump(f2,1)
|
| 30 |
+
endfor
|
| 31 |
+
printf("\n")
|
| 32 |
+
endfor
|
| 33 |
+
fprintf(f2, "\nend");
|
| 34 |
+
fclose(f)
|
| 35 |
+
fclose(f2)
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/cpbeta.sh
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -e
|
| 2 |
+
# This file is part of JTFRAME.
|
| 3 |
+
# JTFRAME program is free software: you can redistribute it and/or modify
|
| 4 |
+
# it under the terms of the GNU General Public License as published by
|
| 5 |
+
# the Free Software Foundation, either version 3 of the License, or
|
| 6 |
+
# (at your option) any later version.
|
| 7 |
+
|
| 8 |
+
# JTFRAME program is distributed in the hope that it will be useful,
|
| 9 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 10 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 11 |
+
# GNU General Public License for more details.
|
| 12 |
+
|
| 13 |
+
# You should have received a copy of the GNU General Public License
|
| 14 |
+
# along with JTFRAME. If not, see <http://www.gnu.org/licenses/>.
|
| 15 |
+
|
| 16 |
+
# Author: Jose Tejada Gomez. Twitter: @topapate
|
| 17 |
+
# Version: 1.0
|
| 18 |
+
# Date: 12-1-2023
|
| 19 |
+
|
| 20 |
+
# Creates the beta zip files from the contents of $JTROOT/release
|
| 21 |
+
# Places a copy of the files in $JTROOT and another one, for
|
| 22 |
+
# archiving purposes in $JTFRIDAY
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
main() {
|
| 26 |
+
parse_args $*
|
| 27 |
+
check_jtfriday_defined
|
| 28 |
+
|
| 29 |
+
make_temp_folder
|
| 30 |
+
copy_all_targets
|
| 31 |
+
|
| 32 |
+
make_zip_files
|
| 33 |
+
archive_zip_files
|
| 34 |
+
clean_up
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
parse_args() {
|
| 38 |
+
FRIDAY="friday"
|
| 39 |
+
while [ $# -gt 0 ]; do
|
| 40 |
+
case "$1" in
|
| 41 |
+
--last)
|
| 42 |
+
FRIDAY="last friday";;
|
| 43 |
+
-h|--help)
|
| 44 |
+
show_help
|
| 45 |
+
exit 0;;
|
| 46 |
+
*)
|
| 47 |
+
echo "Unknown argument $1"
|
| 48 |
+
exit 1;;
|
| 49 |
+
esac
|
| 50 |
+
shift
|
| 51 |
+
done
|
| 52 |
+
SHORTSTAMP=$(date --date="$FRIDAY" +"%y%m%d")
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
show_help() {
|
| 56 |
+
cat<<EOF
|
| 57 |
+
cpbeta.sh <hash> [arguments]
|
| 58 |
+
|
| 59 |
+
Creates zip files for distribution on JTFRIDAY.
|
| 60 |
+
|
| 61 |
+
-h, --help This help screen
|
| 62 |
+
-l, --last Use last friday's date, instead of next's
|
| 63 |
+
or latest published date, if it is more recent
|
| 64 |
+
than last friday's
|
| 65 |
+
EOF
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
check_jtfriday_defined() {
|
| 69 |
+
if [ ! -d "$JTFRIDAY" ]; then
|
| 70 |
+
cat <<EOF
|
| 71 |
+
Missing JTFRIDAY variable pointing to the destination folder
|
| 72 |
+
Define it if you want to archive a copy of the zip files there
|
| 73 |
+
EOF
|
| 74 |
+
exit 1
|
| 75 |
+
fi
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
make_temp_folder() {
|
| 79 |
+
DEST=`mktemp --directory`
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
copy_all_targets() {
|
| 83 |
+
copy_mister_files
|
| 84 |
+
copy_mist_sidi_files
|
| 85 |
+
copy_pocket_files
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
copy_mister_files() {
|
| 89 |
+
mkdir -p "$DEST"/_Arcade/cores "$DEST/mra"
|
| 90 |
+
mkdir -p $DEST/games/mame
|
| 91 |
+
cp $JTUTIL/jtbeta.zip $DEST/games/mame
|
| 92 |
+
cp $JTBIN/mister/*rbf "$DEST"/_Arcade/cores
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
copy_mist_sidi_files() {
|
| 96 |
+
cp -r $JTBIN/mra/* "$DEST"/_Arcade
|
| 97 |
+
cp -r $JTBIN/{mist,sidi,sidi128,mra} "$DEST"
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
copy_pocket_files() {
|
| 101 |
+
mkdir -p $DEST/pocket/Assets/jtpatreon/common
|
| 102 |
+
cp -r $JTBIN/pocket/raw/* $DEST/pocket
|
| 103 |
+
unzip -q $JTUTIL/jtbeta.zip -d $DEST/pocket/Assets/jtpatreon/common
|
| 104 |
+
mkdir $DEST/pocket/readme
|
| 105 |
+
mv $DEST/pocket/*.txt $DEST/pocket/readme
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
make_zip_files() {
|
| 109 |
+
cd $DEST
|
| 110 |
+
cat >zip_comment <<EOF
|
| 111 |
+
-- JOTEGO --
|
| 112 |
+
|
| 113 |
+
Beta files for Patreon supporters.
|
| 114 |
+
https://www.patreon.com/jotego
|
| 115 |
+
|
| 116 |
+
EOF
|
| 117 |
+
betazip jtfriday_${SHORTSTAMP}_mister.zip _Arcade games &
|
| 118 |
+
betazip jtfriday_${SHORTSTAMP}_pocket.zip mra pocket &
|
| 119 |
+
betazip jtfriday_${SHORTSTAMP}_other.zip mra mist sidi* &
|
| 120 |
+
wait
|
| 121 |
+
cp *.zip $JTROOT
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
betazip() {
|
| 125 |
+
cat $DEST/zip_comment | zip -qr --test --archive-comment -9 $*
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
archive_zip_files() {
|
| 130 |
+
ZIPDEST="$JTFRIDAY"/$SHORTSTAMP
|
| 131 |
+
mkdir -p "$ZIPDEST"
|
| 132 |
+
cp *.zip "$ZIPDEST"
|
| 133 |
+
cp $JTUTIL/jtbeta.zip "$ZIPDEST"
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
clean_up() {
|
| 137 |
+
cd $JTROOT
|
| 138 |
+
rm -rf $DEST
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
main $*
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/cprbf.sh
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# Copy files from JTBIN to the local JTROOT/release folder
|
| 4 |
+
# Useful to prepare a release folder where new MRAs will be tested
|
| 5 |
+
# using an old RBF
|
| 6 |
+
|
| 7 |
+
for i in $*; do
|
| 8 |
+
SRC=$JTBIN/mister/$i/releases/jt$i.rbf
|
| 9 |
+
DST=$JTROOT/release/mister/$i/releases
|
| 10 |
+
if [ ! -e $SRC ]; then
|
| 11 |
+
echo "The core $i does not exist in JTBIN. Skipping it"
|
| 12 |
+
echo "Cannot find $SRC"
|
| 13 |
+
continue
|
| 14 |
+
fi
|
| 15 |
+
if [ ! -d $DST ]; then
|
| 16 |
+
echo "Regenerating MRA files"
|
| 17 |
+
jtframe mra $i
|
| 18 |
+
fi
|
| 19 |
+
cp -v $SRC $DST
|
| 20 |
+
# Copy MiST and SiDi if they exist
|
| 21 |
+
for AUX in mist sidi; do
|
| 22 |
+
SRC=$JTBIN/$AUX/jt$i.rbf
|
| 23 |
+
if [ -e $SRC ]; then
|
| 24 |
+
mkdir -p $JTROOT/release/$AUX
|
| 25 |
+
cp -v $SRC $JTROOT/release/$AUX
|
| 26 |
+
else
|
| 27 |
+
echo "$AUX version of $i not found at $SRC"
|
| 28 |
+
fi
|
| 29 |
+
done
|
| 30 |
+
done
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/dump.m
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function dump(f2,val)
|
| 2 |
+
global cnt
|
| 3 |
+
fprintf(f2,"bkg[%4d]=8'h%02X; ",cnt,val)
|
| 4 |
+
cnt=cnt+1;
|
| 5 |
+
if mod(cnt,16)==0
|
| 6 |
+
fprintf(f2,"\n")
|
| 7 |
+
endif
|
| 8 |
+
endfunction
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/extract2mr.sh
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -e
|
| 2 |
+
ZIPFOLDER=/gdrive/jotego/core-builds/
|
| 3 |
+
COMMIT=`find $ZIPFOLDER -name ${1}"*" | head -n 1`
|
| 4 |
+
if [[ -z "$COMMIT" || ! -e $COMMIT ]]; then
|
| 5 |
+
echo "Cannot find $1 in $ZIPFOLDER"
|
| 6 |
+
exit 1
|
| 7 |
+
fi
|
| 8 |
+
|
| 9 |
+
if [ -z "$MISTERPASSWD" ]; then
|
| 10 |
+
echo "Define the MiSTer password in the environment variable MISTERPASSWD"
|
| 11 |
+
exit 1
|
| 12 |
+
fi
|
| 13 |
+
|
| 14 |
+
unzip -j $COMMIT release/mister/neogeopocket.rbf -d /tmp
|
| 15 |
+
sshpass -p $MISTERPASSWD scp /tmp/neogeopocket.rbf root@mister.home:/media/fat/_Console
|
| 16 |
+
rm /tmp/neogeopocket.rbf
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/filechange.sh
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# Report which cores are affected by the last commit
|
| 4 |
+
|
| 5 |
+
GITLOG=`mktemp`
|
| 6 |
+
GITMOD=`mktemp`
|
| 7 |
+
|
| 8 |
+
function get_git_modules {
|
| 9 |
+
grep path .gitmodules > "$GITLOG"
|
| 10 |
+
sed -i "s/[ \t]*path = //" "$GITLOG"
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
function check_core {
|
| 14 |
+
local CORENAME=$1
|
| 15 |
+
if [ ! -e $CORES/$CORENAME/cfg/macros.def ]; then return 0; fi
|
| 16 |
+
if ! jtframe files plain $CORENAME; then return 0; fi
|
| 17 |
+
while IFS= read -r LINE; do
|
| 18 |
+
# reduce submodule files to just the module path
|
| 19 |
+
while IFS= read -r MOD; do
|
| 20 |
+
if [[ $LINE == "$MOD"* ]]; then
|
| 21 |
+
LINE=$MOD
|
| 22 |
+
fi
|
| 23 |
+
done < $GITMOD
|
| 24 |
+
|
| 25 |
+
if grep -q "$LINE" $GITLOG; then
|
| 26 |
+
CHANGED="$CHANGED $CORENAME"
|
| 27 |
+
echo $CORENAME $LINE
|
| 28 |
+
return 0
|
| 29 |
+
fi
|
| 30 |
+
done < files
|
| 31 |
+
return 1
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
function get_changed_files {
|
| 35 |
+
local IDs="$*"
|
| 36 |
+
if [ -z "$IDs" ]; then IDs=`git rev-parse HEAD`; fi
|
| 37 |
+
|
| 38 |
+
# for each commit ID, compare the files changed with those used by each core
|
| 39 |
+
for ID in $IDs; do
|
| 40 |
+
git diff-tree --no-commit-id --name-only -r $ID > "$GITLOG"
|
| 41 |
+
for i in $CORES/*; do
|
| 42 |
+
check_core `basename $i`
|
| 43 |
+
done
|
| 44 |
+
done
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
function clean_up {
|
| 48 |
+
rm -f $GITLOG $GITMOD
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
function show_one_game {
|
| 52 |
+
jtframe mra $1 --skipMRA --skipPocket --skipROM --mainonly --names 2>/dev/null | sort --random-sort | head -n 1
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
function sort_file {
|
| 56 |
+
local temp=`mktemp`
|
| 57 |
+
sort $1 > temp
|
| 58 |
+
mv temp $1
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
function make_github_issue {
|
| 62 |
+
local ISSUE=`mktemp`
|
| 63 |
+
echo "# Main titles affected" > $ISSUE
|
| 64 |
+
for core in $CHANGED; do
|
| 65 |
+
game=`show_one_game $core`
|
| 66 |
+
if [ -z "$game" ]; then continue; fi
|
| 67 |
+
echo "$game" | sed "s/^/- \[ \] /" >> $ISSUE
|
| 68 |
+
done
|
| 69 |
+
sort_file $ISSUE
|
| 70 |
+
echo $(wc -l $ISSUE) "games to be tested"
|
| 71 |
+
gh issue create --assignee jtmiki --body-file $ISSUE --title "Regression test (`date +%Y-%M-%d`)" --label regression
|
| 72 |
+
rm -f $ISSUE
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
# main
|
| 76 |
+
cd $JTROOT
|
| 77 |
+
get_git_modules
|
| 78 |
+
get_changed_files
|
| 79 |
+
|
| 80 |
+
# Display the main titles affected
|
| 81 |
+
if [ -z "$CHANGED" ]; then
|
| 82 |
+
clean_up
|
| 83 |
+
exit 0
|
| 84 |
+
fi
|
| 85 |
+
|
| 86 |
+
make_github_issue
|
| 87 |
+
clean_up
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/font0.hex
ADDED
|
@@ -0,0 +1,1024 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
| 35 |
+
60
|
| 36 |
+
3c
|
| 37 |
+
6
|
| 38 |
+
7c
|
| 39 |
+
18
|
| 40 |
+
0
|
| 41 |
+
0
|
| 42 |
+
66
|
| 43 |
+
6c
|
| 44 |
+
18
|
| 45 |
+
30
|
| 46 |
+
66
|
| 47 |
+
46
|
| 48 |
+
0
|
| 49 |
+
1c
|
| 50 |
+
36
|
| 51 |
+
1c
|
| 52 |
+
38
|
| 53 |
+
6f
|
| 54 |
+
66
|
| 55 |
+
3b
|
| 56 |
+
0
|
| 57 |
+
0
|
| 58 |
+
18
|
| 59 |
+
18
|
| 60 |
+
18
|
| 61 |
+
0
|
| 62 |
+
0
|
| 63 |
+
0
|
| 64 |
+
0
|
| 65 |
+
0
|
| 66 |
+
e
|
| 67 |
+
1c
|
| 68 |
+
18
|
| 69 |
+
18
|
| 70 |
+
1c
|
| 71 |
+
e
|
| 72 |
+
0
|
| 73 |
+
0
|
| 74 |
+
70
|
| 75 |
+
38
|
| 76 |
+
18
|
| 77 |
+
18
|
| 78 |
+
38
|
| 79 |
+
70
|
| 80 |
+
0
|
| 81 |
+
0
|
| 82 |
+
66
|
| 83 |
+
3c
|
| 84 |
+
ff
|
| 85 |
+
3c
|
| 86 |
+
66
|
| 87 |
+
0
|
| 88 |
+
0
|
| 89 |
+
0
|
| 90 |
+
18
|
| 91 |
+
18
|
| 92 |
+
7e
|
| 93 |
+
18
|
| 94 |
+
18
|
| 95 |
+
0
|
| 96 |
+
0
|
| 97 |
+
0
|
| 98 |
+
0
|
| 99 |
+
0
|
| 100 |
+
0
|
| 101 |
+
0
|
| 102 |
+
18
|
| 103 |
+
18
|
| 104 |
+
30
|
| 105 |
+
0
|
| 106 |
+
0
|
| 107 |
+
0
|
| 108 |
+
7e
|
| 109 |
+
0
|
| 110 |
+
0
|
| 111 |
+
0
|
| 112 |
+
0
|
| 113 |
+
0
|
| 114 |
+
0
|
| 115 |
+
0
|
| 116 |
+
0
|
| 117 |
+
0
|
| 118 |
+
18
|
| 119 |
+
18
|
| 120 |
+
0
|
| 121 |
+
0
|
| 122 |
+
6
|
| 123 |
+
c
|
| 124 |
+
18
|
| 125 |
+
30
|
| 126 |
+
60
|
| 127 |
+
40
|
| 128 |
+
0
|
| 129 |
+
0
|
| 130 |
+
3c
|
| 131 |
+
66
|
| 132 |
+
6e
|
| 133 |
+
76
|
| 134 |
+
66
|
| 135 |
+
3c
|
| 136 |
+
0
|
| 137 |
+
0
|
| 138 |
+
18
|
| 139 |
+
38
|
| 140 |
+
18
|
| 141 |
+
18
|
| 142 |
+
18
|
| 143 |
+
7e
|
| 144 |
+
0
|
| 145 |
+
0
|
| 146 |
+
3c
|
| 147 |
+
66
|
| 148 |
+
c
|
| 149 |
+
18
|
| 150 |
+
30
|
| 151 |
+
7e
|
| 152 |
+
0
|
| 153 |
+
0
|
| 154 |
+
7e
|
| 155 |
+
c
|
| 156 |
+
18
|
| 157 |
+
c
|
| 158 |
+
66
|
| 159 |
+
3c
|
| 160 |
+
0
|
| 161 |
+
0
|
| 162 |
+
c
|
| 163 |
+
1c
|
| 164 |
+
3c
|
| 165 |
+
6c
|
| 166 |
+
7e
|
| 167 |
+
c
|
| 168 |
+
0
|
| 169 |
+
0
|
| 170 |
+
7e
|
| 171 |
+
60
|
| 172 |
+
7c
|
| 173 |
+
6
|
| 174 |
+
66
|
| 175 |
+
3c
|
| 176 |
+
0
|
| 177 |
+
0
|
| 178 |
+
3c
|
| 179 |
+
60
|
| 180 |
+
7c
|
| 181 |
+
66
|
| 182 |
+
66
|
| 183 |
+
3c
|
| 184 |
+
0
|
| 185 |
+
0
|
| 186 |
+
7e
|
| 187 |
+
6
|
| 188 |
+
c
|
| 189 |
+
18
|
| 190 |
+
30
|
| 191 |
+
30
|
| 192 |
+
0
|
| 193 |
+
0
|
| 194 |
+
3c
|
| 195 |
+
66
|
| 196 |
+
3c
|
| 197 |
+
66
|
| 198 |
+
66
|
| 199 |
+
3c
|
| 200 |
+
0
|
| 201 |
+
0
|
| 202 |
+
3c
|
| 203 |
+
66
|
| 204 |
+
3e
|
| 205 |
+
6
|
| 206 |
+
c
|
| 207 |
+
38
|
| 208 |
+
0
|
| 209 |
+
0
|
| 210 |
+
0
|
| 211 |
+
18
|
| 212 |
+
18
|
| 213 |
+
0
|
| 214 |
+
18
|
| 215 |
+
18
|
| 216 |
+
0
|
| 217 |
+
0
|
| 218 |
+
0
|
| 219 |
+
18
|
| 220 |
+
18
|
| 221 |
+
0
|
| 222 |
+
18
|
| 223 |
+
18
|
| 224 |
+
30
|
| 225 |
+
6
|
| 226 |
+
c
|
| 227 |
+
18
|
| 228 |
+
30
|
| 229 |
+
18
|
| 230 |
+
c
|
| 231 |
+
6
|
| 232 |
+
0
|
| 233 |
+
0
|
| 234 |
+
0
|
| 235 |
+
7e
|
| 236 |
+
0
|
| 237 |
+
0
|
| 238 |
+
7e
|
| 239 |
+
0
|
| 240 |
+
0
|
| 241 |
+
60
|
| 242 |
+
30
|
| 243 |
+
18
|
| 244 |
+
c
|
| 245 |
+
18
|
| 246 |
+
30
|
| 247 |
+
60
|
| 248 |
+
0
|
| 249 |
+
0
|
| 250 |
+
3c
|
| 251 |
+
66
|
| 252 |
+
c
|
| 253 |
+
18
|
| 254 |
+
0
|
| 255 |
+
18
|
| 256 |
+
0
|
| 257 |
+
0
|
| 258 |
+
3c
|
| 259 |
+
66
|
| 260 |
+
6e
|
| 261 |
+
6e
|
| 262 |
+
60
|
| 263 |
+
3e
|
| 264 |
+
0
|
| 265 |
+
0
|
| 266 |
+
18
|
| 267 |
+
3c
|
| 268 |
+
66
|
| 269 |
+
66
|
| 270 |
+
7e
|
| 271 |
+
66
|
| 272 |
+
0
|
| 273 |
+
0
|
| 274 |
+
7c
|
| 275 |
+
66
|
| 276 |
+
7c
|
| 277 |
+
66
|
| 278 |
+
66
|
| 279 |
+
7c
|
| 280 |
+
0
|
| 281 |
+
0
|
| 282 |
+
3c
|
| 283 |
+
66
|
| 284 |
+
60
|
| 285 |
+
60
|
| 286 |
+
66
|
| 287 |
+
3c
|
| 288 |
+
0
|
| 289 |
+
0
|
| 290 |
+
78
|
| 291 |
+
6c
|
| 292 |
+
66
|
| 293 |
+
66
|
| 294 |
+
6c
|
| 295 |
+
78
|
| 296 |
+
0
|
| 297 |
+
0
|
| 298 |
+
7e
|
| 299 |
+
60
|
| 300 |
+
7c
|
| 301 |
+
60
|
| 302 |
+
60
|
| 303 |
+
7e
|
| 304 |
+
0
|
| 305 |
+
0
|
| 306 |
+
7e
|
| 307 |
+
60
|
| 308 |
+
7c
|
| 309 |
+
60
|
| 310 |
+
60
|
| 311 |
+
60
|
| 312 |
+
0
|
| 313 |
+
0
|
| 314 |
+
3e
|
| 315 |
+
60
|
| 316 |
+
60
|
| 317 |
+
6e
|
| 318 |
+
66
|
| 319 |
+
3e
|
| 320 |
+
0
|
| 321 |
+
0
|
| 322 |
+
66
|
| 323 |
+
66
|
| 324 |
+
7e
|
| 325 |
+
66
|
| 326 |
+
66
|
| 327 |
+
66
|
| 328 |
+
0
|
| 329 |
+
0
|
| 330 |
+
7e
|
| 331 |
+
18
|
| 332 |
+
18
|
| 333 |
+
18
|
| 334 |
+
18
|
| 335 |
+
7e
|
| 336 |
+
0
|
| 337 |
+
0
|
| 338 |
+
e
|
| 339 |
+
6
|
| 340 |
+
6
|
| 341 |
+
6
|
| 342 |
+
66
|
| 343 |
+
3c
|
| 344 |
+
0
|
| 345 |
+
0
|
| 346 |
+
66
|
| 347 |
+
6c
|
| 348 |
+
78
|
| 349 |
+
78
|
| 350 |
+
6c
|
| 351 |
+
66
|
| 352 |
+
0
|
| 353 |
+
0
|
| 354 |
+
60
|
| 355 |
+
60
|
| 356 |
+
60
|
| 357 |
+
60
|
| 358 |
+
60
|
| 359 |
+
7e
|
| 360 |
+
0
|
| 361 |
+
0
|
| 362 |
+
63
|
| 363 |
+
77
|
| 364 |
+
7f
|
| 365 |
+
6b
|
| 366 |
+
63
|
| 367 |
+
63
|
| 368 |
+
0
|
| 369 |
+
0
|
| 370 |
+
66
|
| 371 |
+
76
|
| 372 |
+
7e
|
| 373 |
+
7e
|
| 374 |
+
6e
|
| 375 |
+
66
|
| 376 |
+
0
|
| 377 |
+
0
|
| 378 |
+
3c
|
| 379 |
+
66
|
| 380 |
+
66
|
| 381 |
+
66
|
| 382 |
+
66
|
| 383 |
+
3c
|
| 384 |
+
0
|
| 385 |
+
0
|
| 386 |
+
7c
|
| 387 |
+
66
|
| 388 |
+
66
|
| 389 |
+
7c
|
| 390 |
+
60
|
| 391 |
+
60
|
| 392 |
+
0
|
| 393 |
+
0
|
| 394 |
+
3c
|
| 395 |
+
66
|
| 396 |
+
66
|
| 397 |
+
66
|
| 398 |
+
6c
|
| 399 |
+
36
|
| 400 |
+
0
|
| 401 |
+
0
|
| 402 |
+
7c
|
| 403 |
+
66
|
| 404 |
+
66
|
| 405 |
+
7c
|
| 406 |
+
6c
|
| 407 |
+
66
|
| 408 |
+
0
|
| 409 |
+
0
|
| 410 |
+
3c
|
| 411 |
+
60
|
| 412 |
+
3c
|
| 413 |
+
6
|
| 414 |
+
6
|
| 415 |
+
3c
|
| 416 |
+
0
|
| 417 |
+
0
|
| 418 |
+
7e
|
| 419 |
+
18
|
| 420 |
+
18
|
| 421 |
+
18
|
| 422 |
+
18
|
| 423 |
+
18
|
| 424 |
+
0
|
| 425 |
+
0
|
| 426 |
+
66
|
| 427 |
+
66
|
| 428 |
+
66
|
| 429 |
+
66
|
| 430 |
+
66
|
| 431 |
+
7e
|
| 432 |
+
0
|
| 433 |
+
0
|
| 434 |
+
66
|
| 435 |
+
66
|
| 436 |
+
66
|
| 437 |
+
66
|
| 438 |
+
3c
|
| 439 |
+
18
|
| 440 |
+
0
|
| 441 |
+
0
|
| 442 |
+
63
|
| 443 |
+
63
|
| 444 |
+
6b
|
| 445 |
+
7f
|
| 446 |
+
77
|
| 447 |
+
63
|
| 448 |
+
0
|
| 449 |
+
0
|
| 450 |
+
66
|
| 451 |
+
66
|
| 452 |
+
3c
|
| 453 |
+
3c
|
| 454 |
+
66
|
| 455 |
+
66
|
| 456 |
+
0
|
| 457 |
+
0
|
| 458 |
+
66
|
| 459 |
+
66
|
| 460 |
+
3c
|
| 461 |
+
18
|
| 462 |
+
18
|
| 463 |
+
18
|
| 464 |
+
0
|
| 465 |
+
0
|
| 466 |
+
7e
|
| 467 |
+
c
|
| 468 |
+
18
|
| 469 |
+
30
|
| 470 |
+
60
|
| 471 |
+
7e
|
| 472 |
+
0
|
| 473 |
+
0
|
| 474 |
+
1e
|
| 475 |
+
18
|
| 476 |
+
18
|
| 477 |
+
18
|
| 478 |
+
18
|
| 479 |
+
1e
|
| 480 |
+
0
|
| 481 |
+
0
|
| 482 |
+
40
|
| 483 |
+
60
|
| 484 |
+
30
|
| 485 |
+
18
|
| 486 |
+
c
|
| 487 |
+
6
|
| 488 |
+
0
|
| 489 |
+
0
|
| 490 |
+
78
|
| 491 |
+
18
|
| 492 |
+
18
|
| 493 |
+
18
|
| 494 |
+
18
|
| 495 |
+
78
|
| 496 |
+
0
|
| 497 |
+
0
|
| 498 |
+
8
|
| 499 |
+
1c
|
| 500 |
+
36
|
| 501 |
+
63
|
| 502 |
+
0
|
| 503 |
+
0
|
| 504 |
+
0
|
| 505 |
+
0
|
| 506 |
+
0
|
| 507 |
+
0
|
| 508 |
+
0
|
| 509 |
+
0
|
| 510 |
+
0
|
| 511 |
+
ff
|
| 512 |
+
0
|
| 513 |
+
0
|
| 514 |
+
18
|
| 515 |
+
3c
|
| 516 |
+
7e
|
| 517 |
+
7e
|
| 518 |
+
3c
|
| 519 |
+
18
|
| 520 |
+
0
|
| 521 |
+
0
|
| 522 |
+
0
|
| 523 |
+
3c
|
| 524 |
+
6
|
| 525 |
+
3e
|
| 526 |
+
66
|
| 527 |
+
3e
|
| 528 |
+
0
|
| 529 |
+
0
|
| 530 |
+
60
|
| 531 |
+
60
|
| 532 |
+
7c
|
| 533 |
+
66
|
| 534 |
+
66
|
| 535 |
+
7c
|
| 536 |
+
0
|
| 537 |
+
0
|
| 538 |
+
0
|
| 539 |
+
3c
|
| 540 |
+
60
|
| 541 |
+
60
|
| 542 |
+
60
|
| 543 |
+
3c
|
| 544 |
+
0
|
| 545 |
+
0
|
| 546 |
+
6
|
| 547 |
+
6
|
| 548 |
+
3e
|
| 549 |
+
66
|
| 550 |
+
66
|
| 551 |
+
3e
|
| 552 |
+
0
|
| 553 |
+
0
|
| 554 |
+
0
|
| 555 |
+
3c
|
| 556 |
+
66
|
| 557 |
+
7e
|
| 558 |
+
60
|
| 559 |
+
3c
|
| 560 |
+
0
|
| 561 |
+
0
|
| 562 |
+
e
|
| 563 |
+
18
|
| 564 |
+
3e
|
| 565 |
+
18
|
| 566 |
+
18
|
| 567 |
+
18
|
| 568 |
+
0
|
| 569 |
+
0
|
| 570 |
+
0
|
| 571 |
+
3e
|
| 572 |
+
66
|
| 573 |
+
66
|
| 574 |
+
3e
|
| 575 |
+
6
|
| 576 |
+
7c
|
| 577 |
+
0
|
| 578 |
+
60
|
| 579 |
+
60
|
| 580 |
+
7c
|
| 581 |
+
66
|
| 582 |
+
66
|
| 583 |
+
66
|
| 584 |
+
0
|
| 585 |
+
0
|
| 586 |
+
18
|
| 587 |
+
0
|
| 588 |
+
38
|
| 589 |
+
18
|
| 590 |
+
18
|
| 591 |
+
3c
|
| 592 |
+
0
|
| 593 |
+
0
|
| 594 |
+
6
|
| 595 |
+
0
|
| 596 |
+
6
|
| 597 |
+
6
|
| 598 |
+
6
|
| 599 |
+
6
|
| 600 |
+
3c
|
| 601 |
+
0
|
| 602 |
+
60
|
| 603 |
+
60
|
| 604 |
+
6c
|
| 605 |
+
78
|
| 606 |
+
6c
|
| 607 |
+
66
|
| 608 |
+
0
|
| 609 |
+
0
|
| 610 |
+
38
|
| 611 |
+
18
|
| 612 |
+
18
|
| 613 |
+
18
|
| 614 |
+
18
|
| 615 |
+
3c
|
| 616 |
+
0
|
| 617 |
+
0
|
| 618 |
+
0
|
| 619 |
+
66
|
| 620 |
+
7f
|
| 621 |
+
7f
|
| 622 |
+
6b
|
| 623 |
+
63
|
| 624 |
+
0
|
| 625 |
+
0
|
| 626 |
+
0
|
| 627 |
+
7c
|
| 628 |
+
66
|
| 629 |
+
66
|
| 630 |
+
66
|
| 631 |
+
66
|
| 632 |
+
0
|
| 633 |
+
0
|
| 634 |
+
0
|
| 635 |
+
3c
|
| 636 |
+
66
|
| 637 |
+
66
|
| 638 |
+
66
|
| 639 |
+
3c
|
| 640 |
+
0
|
| 641 |
+
0
|
| 642 |
+
0
|
| 643 |
+
7c
|
| 644 |
+
66
|
| 645 |
+
66
|
| 646 |
+
7c
|
| 647 |
+
60
|
| 648 |
+
60
|
| 649 |
+
0
|
| 650 |
+
0
|
| 651 |
+
3e
|
| 652 |
+
66
|
| 653 |
+
66
|
| 654 |
+
3e
|
| 655 |
+
6
|
| 656 |
+
6
|
| 657 |
+
0
|
| 658 |
+
0
|
| 659 |
+
7c
|
| 660 |
+
66
|
| 661 |
+
60
|
| 662 |
+
60
|
| 663 |
+
60
|
| 664 |
+
0
|
| 665 |
+
0
|
| 666 |
+
0
|
| 667 |
+
3e
|
| 668 |
+
60
|
| 669 |
+
3c
|
| 670 |
+
6
|
| 671 |
+
7c
|
| 672 |
+
0
|
| 673 |
+
0
|
| 674 |
+
18
|
| 675 |
+
7e
|
| 676 |
+
18
|
| 677 |
+
18
|
| 678 |
+
18
|
| 679 |
+
e
|
| 680 |
+
0
|
| 681 |
+
0
|
| 682 |
+
0
|
| 683 |
+
66
|
| 684 |
+
66
|
| 685 |
+
66
|
| 686 |
+
66
|
| 687 |
+
3e
|
| 688 |
+
0
|
| 689 |
+
0
|
| 690 |
+
0
|
| 691 |
+
66
|
| 692 |
+
66
|
| 693 |
+
66
|
| 694 |
+
3c
|
| 695 |
+
18
|
| 696 |
+
0
|
| 697 |
+
0
|
| 698 |
+
0
|
| 699 |
+
63
|
| 700 |
+
6b
|
| 701 |
+
7f
|
| 702 |
+
3e
|
| 703 |
+
36
|
| 704 |
+
0
|
| 705 |
+
0
|
| 706 |
+
0
|
| 707 |
+
66
|
| 708 |
+
3c
|
| 709 |
+
18
|
| 710 |
+
3c
|
| 711 |
+
66
|
| 712 |
+
0
|
| 713 |
+
0
|
| 714 |
+
0
|
| 715 |
+
66
|
| 716 |
+
66
|
| 717 |
+
66
|
| 718 |
+
3e
|
| 719 |
+
c
|
| 720 |
+
78
|
| 721 |
+
0
|
| 722 |
+
0
|
| 723 |
+
7e
|
| 724 |
+
c
|
| 725 |
+
18
|
| 726 |
+
30
|
| 727 |
+
7e
|
| 728 |
+
0
|
| 729 |
+
0
|
| 730 |
+
18
|
| 731 |
+
3c
|
| 732 |
+
7e
|
| 733 |
+
7e
|
| 734 |
+
18
|
| 735 |
+
3c
|
| 736 |
+
0
|
| 737 |
+
18
|
| 738 |
+
18
|
| 739 |
+
18
|
| 740 |
+
18
|
| 741 |
+
18
|
| 742 |
+
18
|
| 743 |
+
18
|
| 744 |
+
18
|
| 745 |
+
0
|
| 746 |
+
7e
|
| 747 |
+
78
|
| 748 |
+
7c
|
| 749 |
+
6e
|
| 750 |
+
66
|
| 751 |
+
6
|
| 752 |
+
0
|
| 753 |
+
8
|
| 754 |
+
18
|
| 755 |
+
38
|
| 756 |
+
78
|
| 757 |
+
38
|
| 758 |
+
18
|
| 759 |
+
8
|
| 760 |
+
0
|
| 761 |
+
fe
|
| 762 |
+
fe
|
| 763 |
+
fe
|
| 764 |
+
fe
|
| 765 |
+
fe
|
| 766 |
+
fe
|
| 767 |
+
fe
|
| 768 |
+
0
|
| 769 |
+
a8
|
| 770 |
+
97
|
| 771 |
+
d5
|
| 772 |
+
b1
|
| 773 |
+
8b
|
| 774 |
+
7f
|
| 775 |
+
0
|
| 776 |
+
0
|
| 777 |
+
0
|
| 778 |
+
9b
|
| 779 |
+
d5
|
| 780 |
+
b1
|
| 781 |
+
8b
|
| 782 |
+
7f
|
| 783 |
+
0
|
| 784 |
+
0
|
| 785 |
+
24
|
| 786 |
+
b9
|
| 787 |
+
d5
|
| 788 |
+
b1
|
| 789 |
+
8b
|
| 790 |
+
7f
|
| 791 |
+
0
|
| 792 |
+
0
|
| 793 |
+
7b
|
| 794 |
+
ef
|
| 795 |
+
af
|
| 796 |
+
b1
|
| 797 |
+
8b
|
| 798 |
+
7f
|
| 799 |
+
0
|
| 800 |
+
0
|
| 801 |
+
78
|
| 802 |
+
98
|
| 803 |
+
d5
|
| 804 |
+
b1
|
| 805 |
+
8b
|
| 806 |
+
7f
|
| 807 |
+
0
|
| 808 |
+
0
|
| 809 |
+
56
|
| 810 |
+
d4
|
| 811 |
+
ac
|
| 812 |
+
b1
|
| 813 |
+
8b
|
| 814 |
+
7f
|
| 815 |
+
0
|
| 816 |
+
0
|
| 817 |
+
e8
|
| 818 |
+
99
|
| 819 |
+
d5
|
| 820 |
+
b1
|
| 821 |
+
8b
|
| 822 |
+
7f
|
| 823 |
+
0
|
| 824 |
+
0
|
| 825 |
+
a8
|
| 826 |
+
97
|
| 827 |
+
d5
|
| 828 |
+
b1
|
| 829 |
+
8b
|
| 830 |
+
7f
|
| 831 |
+
0
|
| 832 |
+
0
|
| 833 |
+
60
|
| 834 |
+
92
|
| 835 |
+
d5
|
| 836 |
+
b1
|
| 837 |
+
8b
|
| 838 |
+
7f
|
| 839 |
+
0
|
| 840 |
+
0
|
| 841 |
+
20
|
| 842 |
+
d8
|
| 843 |
+
ac
|
| 844 |
+
b1
|
| 845 |
+
8b
|
| 846 |
+
7f
|
| 847 |
+
0
|
| 848 |
+
0
|
| 849 |
+
e0
|
| 850 |
+
99
|
| 851 |
+
d5
|
| 852 |
+
b1
|
| 853 |
+
8b
|
| 854 |
+
7f
|
| 855 |
+
0
|
| 856 |
+
0
|
| 857 |
+
c0
|
| 858 |
+
98
|
| 859 |
+
d5
|
| 860 |
+
b1
|
| 861 |
+
8b
|
| 862 |
+
7f
|
| 863 |
+
0
|
| 864 |
+
0
|
| 865 |
+
e0
|
| 866 |
+
99
|
| 867 |
+
d5
|
| 868 |
+
b1
|
| 869 |
+
8b
|
| 870 |
+
7f
|
| 871 |
+
0
|
| 872 |
+
0
|
| 873 |
+
28
|
| 874 |
+
36
|
| 875 |
+
9d
|
| 876 |
+
b1
|
| 877 |
+
8b
|
| 878 |
+
7f
|
| 879 |
+
0
|
| 880 |
+
0
|
| 881 |
+
40
|
| 882 |
+
7a
|
| 883 |
+
a7
|
| 884 |
+
b1
|
| 885 |
+
8b
|
| 886 |
+
7f
|
| 887 |
+
0
|
| 888 |
+
0
|
| 889 |
+
89
|
| 890 |
+
64
|
| 891 |
+
62
|
| 892 |
+
b1
|
| 893 |
+
8b
|
| 894 |
+
7f
|
| 895 |
+
0
|
| 896 |
+
0
|
| 897 |
+
30
|
| 898 |
+
95
|
| 899 |
+
c5
|
| 900 |
+
dc
|
| 901 |
+
fe
|
| 902 |
+
7f
|
| 903 |
+
0
|
| 904 |
+
0
|
| 905 |
+
1
|
| 906 |
+
0
|
| 907 |
+
0
|
| 908 |
+
0
|
| 909 |
+
0
|
| 910 |
+
0
|
| 911 |
+
0
|
| 912 |
+
0
|
| 913 |
+
30
|
| 914 |
+
95
|
| 915 |
+
c5
|
| 916 |
+
dc
|
| 917 |
+
fe
|
| 918 |
+
7f
|
| 919 |
+
0
|
| 920 |
+
0
|
| 921 |
+
60
|
| 922 |
+
4d
|
| 923 |
+
8
|
| 924 |
+
11
|
| 925 |
+
e2
|
| 926 |
+
55
|
| 927 |
+
0
|
| 928 |
+
0
|
| 929 |
+
1
|
| 930 |
+
0
|
| 931 |
+
0
|
| 932 |
+
0
|
| 933 |
+
0
|
| 934 |
+
0
|
| 935 |
+
0
|
| 936 |
+
0
|
| 937 |
+
29
|
| 938 |
+
3b
|
| 939 |
+
e8
|
| 940 |
+
10
|
| 941 |
+
e2
|
| 942 |
+
55
|
| 943 |
+
0
|
| 944 |
+
0
|
| 945 |
+
0
|
| 946 |
+
0
|
| 947 |
+
0
|
| 948 |
+
0
|
| 949 |
+
79
|
| 950 |
+
0
|
| 951 |
+
0
|
| 952 |
+
0
|
| 953 |
+
ff
|
| 954 |
+
ff
|
| 955 |
+
0
|
| 956 |
+
0
|
| 957 |
+
1
|
| 958 |
+
0
|
| 959 |
+
0
|
| 960 |
+
0
|
| 961 |
+
40
|
| 962 |
+
95
|
| 963 |
+
c5
|
| 964 |
+
dc
|
| 965 |
+
fe
|
| 966 |
+
7f
|
| 967 |
+
0
|
| 968 |
+
0
|
| 969 |
+
3f
|
| 970 |
+
3b
|
| 971 |
+
e8
|
| 972 |
+
10
|
| 973 |
+
e2
|
| 974 |
+
55
|
| 975 |
+
0
|
| 976 |
+
0
|
| 977 |
+
2
|
| 978 |
+
0
|
| 979 |
+
0
|
| 980 |
+
0
|
| 981 |
+
0
|
| 982 |
+
0
|
| 983 |
+
0
|
| 984 |
+
0
|
| 985 |
+
ad
|
| 986 |
+
3c
|
| 987 |
+
e8
|
| 988 |
+
10
|
| 989 |
+
e2
|
| 990 |
+
55
|
| 991 |
+
0
|
| 992 |
+
0
|
| 993 |
+
a0
|
| 994 |
+
d9
|
| 995 |
+
d6
|
| 996 |
+
b1
|
| 997 |
+
8b
|
| 998 |
+
7f
|
| 999 |
+
0
|
| 1000 |
+
0
|
| 1001 |
+
0
|
| 1002 |
+
0
|
| 1003 |
+
0
|
| 1004 |
+
0
|
| 1005 |
+
0
|
| 1006 |
+
0
|
| 1007 |
+
0
|
| 1008 |
+
0
|
| 1009 |
+
60
|
| 1010 |
+
3c
|
| 1011 |
+
e8
|
| 1012 |
+
10
|
| 1013 |
+
e2
|
| 1014 |
+
55
|
| 1015 |
+
0
|
| 1016 |
+
0
|
| 1017 |
+
0
|
| 1018 |
+
39
|
| 1019 |
+
e8
|
| 1020 |
+
10
|
| 1021 |
+
e2
|
| 1022 |
+
55
|
| 1023 |
+
0
|
| 1024 |
+
0
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/font0.pf
ADDED
|
Binary file (768 Bytes). View file
|
|
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/getset.sh
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# This file is part of JT_FRAME.
|
| 3 |
+
# JTFRAME program is free software: you can redistribute it and/or modify
|
| 4 |
+
# it under the terms of the GNU General Public License as published by
|
| 5 |
+
# the Free Software Foundation, either version 3 of the License, or
|
| 6 |
+
# (at your option) any later version.
|
| 7 |
+
#
|
| 8 |
+
# JTFRAME program is distributed in the hope that it will be useful,
|
| 9 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 10 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 11 |
+
# GNU General Public License for more details.
|
| 12 |
+
#
|
| 13 |
+
# You should have received a copy of the GNU General Public License
|
| 14 |
+
# along with JTFRAME. If not, see <http://www.gnu.org/licenses/>.
|
| 15 |
+
#
|
| 16 |
+
# Author: Jose Tejada Gomez. Twitter: @topapate
|
| 17 |
+
# Date: 3-1-2023
|
| 18 |
+
|
| 19 |
+
# Finds the right MRA file and extracts the rom file for it
|
| 20 |
+
|
| 21 |
+
if [ $# -lt 2 ]; then
|
| 22 |
+
cat <<EOF
|
| 23 |
+
get.sh <core name> <MAME setname> [options to jtframe mra]
|
| 24 |
+
|
| 25 |
+
Extracts the .rom file and places it in the $ROM folder.
|
| 26 |
+
|
| 27 |
+
1. Regenerates the MRA files by running jtframe mra
|
| 28 |
+
2. Searches through them looking for the right one to parse
|
| 29 |
+
3. Runs the mra or orca tool to get the .rom file
|
| 30 |
+
4. Creates a file in rom/setname.dip with the default DIP
|
| 31 |
+
switches, from MSB to LSB
|
| 32 |
+
EOF
|
| 33 |
+
exit 1
|
| 34 |
+
fi
|
| 35 |
+
|
| 36 |
+
if [ -z "$JTROOT" ]; then
|
| 37 |
+
echo "JTROOT is not defined. Call setprj.sh before getset.sh"
|
| 38 |
+
exit 1
|
| 39 |
+
fi
|
| 40 |
+
|
| 41 |
+
CORENAME=$1
|
| 42 |
+
SETNAME="$2"
|
| 43 |
+
shift
|
| 44 |
+
shift
|
| 45 |
+
# The rest of the arguments are passed to jtframe
|
| 46 |
+
|
| 47 |
+
function require {
|
| 48 |
+
if [ ! -e "$1" ]; then
|
| 49 |
+
echo "getset.sh: cannot find $1"
|
| 50 |
+
exit 1
|
| 51 |
+
fi
|
| 52 |
+
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
require "$CORES/$CORENAME/cfg/mame2mra.toml"
|
| 56 |
+
require "$JTROOT/doc/mame.xml"
|
| 57 |
+
|
| 58 |
+
if [ ! -d ~/.mame/roms ]; then
|
| 59 |
+
echo "Cannot find folder ~/.mame/roms"
|
| 60 |
+
exit 1
|
| 61 |
+
fi
|
| 62 |
+
|
| 63 |
+
AUX=`mktemp`
|
| 64 |
+
if ! jtframe mra $CORENAME $* > $AUX; then
|
| 65 |
+
cat $AUX
|
| 66 |
+
rm $AUX
|
| 67 |
+
exit 1
|
| 68 |
+
fi
|
| 69 |
+
rm $AUX
|
| 70 |
+
|
| 71 |
+
MATCHES=`mktemp`
|
| 72 |
+
|
| 73 |
+
find $JTROOT/release/mra -name "*.mra" -print0 | xargs -0 grep --files-with-matches ">$SETNAME<" > $MATCHES
|
| 74 |
+
case `wc -l $MATCHES | cut -f 1 -d ' '` in
|
| 75 |
+
0)
|
| 76 |
+
echo "Cannot find the required ROM set: $SETNAME in $MRA."
|
| 77 |
+
echo "Check the set name spelling."
|
| 78 |
+
exit 1;;
|
| 79 |
+
1) basename "$(cat $MATCHES)";;
|
| 80 |
+
*)
|
| 81 |
+
echo "getset.sh: More than one MRA file contained $SETNAME"
|
| 82 |
+
cat $MATCHES
|
| 83 |
+
rm $MATCHES
|
| 84 |
+
exit 1;;
|
| 85 |
+
esac
|
| 86 |
+
|
| 87 |
+
# Get the DIP switch configuration
|
| 88 |
+
cd $ROM
|
| 89 |
+
# copy the mra file to a temporary file with a name that will not contain '
|
| 90 |
+
# because xmlstarlet fails with '
|
| 91 |
+
AUX=`mktemp`
|
| 92 |
+
cp "$(cat $MATCHES)" $AUX
|
| 93 |
+
DIPSW=$(xmlstarlet sel -t -m misterromdescription -m switches -v @default $AUX)
|
| 94 |
+
DIPSW=$(echo $DIPSW | tr , '\n' | tac | tr -t '\n' ' ')
|
| 95 |
+
printf "%s%s%s%s" $DIPSW > $SETNAME.dip
|
| 96 |
+
|
| 97 |
+
rm -f $MATCHES $AUX
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/git-prompt.sh
ADDED
|
@@ -0,0 +1,560 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# bash/zsh git prompt support
|
| 2 |
+
#
|
| 3 |
+
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
|
| 4 |
+
# Distributed under the GNU General Public License, version 2.0.
|
| 5 |
+
#
|
| 6 |
+
# This script allows you to see repository status in your prompt.
|
| 7 |
+
#
|
| 8 |
+
# To enable:
|
| 9 |
+
#
|
| 10 |
+
# 1) Copy this file to somewhere (e.g. ~/.git-prompt.sh).
|
| 11 |
+
# 2) Add the following line to your .bashrc/.zshrc:
|
| 12 |
+
# source ~/.git-prompt.sh
|
| 13 |
+
# 3a) Change your PS1 to call __git_ps1 as
|
| 14 |
+
# command-substitution:
|
| 15 |
+
# Bash: PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
|
| 16 |
+
# ZSH: setopt PROMPT_SUBST ; PS1='[%n@%m %c$(__git_ps1 " (%s)")]\$ '
|
| 17 |
+
# the optional argument will be used as format string.
|
| 18 |
+
# 3b) Alternatively, for a slightly faster prompt, __git_ps1 can
|
| 19 |
+
# be used for PROMPT_COMMAND in Bash or for precmd() in Zsh
|
| 20 |
+
# with two parameters, <pre> and <post>, which are strings
|
| 21 |
+
# you would put in $PS1 before and after the status string
|
| 22 |
+
# generated by the git-prompt machinery. e.g.
|
| 23 |
+
# Bash: PROMPT_COMMAND='__git_ps1 "\u@\h:\w" "\\\$ "'
|
| 24 |
+
# will show username, at-sign, host, colon, cwd, then
|
| 25 |
+
# various status string, followed by dollar and SP, as
|
| 26 |
+
# your prompt.
|
| 27 |
+
# ZSH: precmd () { __git_ps1 "%n" ":%~$ " "|%s" }
|
| 28 |
+
# will show username, pipe, then various status string,
|
| 29 |
+
# followed by colon, cwd, dollar and SP, as your prompt.
|
| 30 |
+
# Optionally, you can supply a third argument with a printf
|
| 31 |
+
# format string to finetune the output of the branch status
|
| 32 |
+
#
|
| 33 |
+
# The repository status will be displayed only if you are currently in a
|
| 34 |
+
# git repository. The %s token is the placeholder for the shown status.
|
| 35 |
+
#
|
| 36 |
+
# The prompt status always includes the current branch name.
|
| 37 |
+
#
|
| 38 |
+
# In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty value,
|
| 39 |
+
# unstaged (*) and staged (+) changes will be shown next to the branch
|
| 40 |
+
# name. You can configure this per-repository with the
|
| 41 |
+
# bash.showDirtyState variable, which defaults to true once
|
| 42 |
+
# GIT_PS1_SHOWDIRTYSTATE is enabled.
|
| 43 |
+
#
|
| 44 |
+
# You can also see if currently something is stashed, by setting
|
| 45 |
+
# GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed,
|
| 46 |
+
# then a '$' will be shown next to the branch name.
|
| 47 |
+
#
|
| 48 |
+
# If you would like to see if there're untracked files, then you can set
|
| 49 |
+
# GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're untracked
|
| 50 |
+
# files, then a '%' will be shown next to the branch name. You can
|
| 51 |
+
# configure this per-repository with the bash.showUntrackedFiles
|
| 52 |
+
# variable, which defaults to true once GIT_PS1_SHOWUNTRACKEDFILES is
|
| 53 |
+
# enabled.
|
| 54 |
+
#
|
| 55 |
+
# If you would like to see the difference between HEAD and its upstream,
|
| 56 |
+
# set GIT_PS1_SHOWUPSTREAM="auto". A "<" indicates you are behind, ">"
|
| 57 |
+
# indicates you are ahead, "<>" indicates you have diverged and "="
|
| 58 |
+
# indicates that there is no difference. You can further control
|
| 59 |
+
# behaviour by setting GIT_PS1_SHOWUPSTREAM to a space-separated list
|
| 60 |
+
# of values:
|
| 61 |
+
#
|
| 62 |
+
# verbose show number of commits ahead/behind (+/-) upstream
|
| 63 |
+
# name if verbose, then also show the upstream abbrev name
|
| 64 |
+
# legacy don't use the '--count' option available in recent
|
| 65 |
+
# versions of git-rev-list
|
| 66 |
+
# git always compare HEAD to @{upstream}
|
| 67 |
+
# svn always compare HEAD to your SVN upstream
|
| 68 |
+
#
|
| 69 |
+
# You can change the separator between the branch name and the above
|
| 70 |
+
# state symbols by setting GIT_PS1_STATESEPARATOR. The default separator
|
| 71 |
+
# is SP.
|
| 72 |
+
#
|
| 73 |
+
# By default, __git_ps1 will compare HEAD to your SVN upstream if it can
|
| 74 |
+
# find one, or @{upstream} otherwise. Once you have set
|
| 75 |
+
# GIT_PS1_SHOWUPSTREAM, you can override it on a per-repository basis by
|
| 76 |
+
# setting the bash.showUpstream config variable.
|
| 77 |
+
#
|
| 78 |
+
# If you would like to see more information about the identity of
|
| 79 |
+
# commits checked out as a detached HEAD, set GIT_PS1_DESCRIBE_STYLE
|
| 80 |
+
# to one of these values:
|
| 81 |
+
#
|
| 82 |
+
# contains relative to newer annotated tag (v1.6.3.2~35)
|
| 83 |
+
# branch relative to newer tag or branch (master~4)
|
| 84 |
+
# describe relative to older annotated tag (v1.6.3.1-13-gdd42c2f)
|
| 85 |
+
# tag relative to any older tag (v1.6.3.1-13-gdd42c2f)
|
| 86 |
+
# default exactly matching tag
|
| 87 |
+
#
|
| 88 |
+
# If you would like a colored hint about the current dirty state, set
|
| 89 |
+
# GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on
|
| 90 |
+
# the colored output of "git status -sb" and are available only when
|
| 91 |
+
# using __git_ps1 for PROMPT_COMMAND or precmd.
|
| 92 |
+
#
|
| 93 |
+
# If you would like __git_ps1 to do nothing in the case when the current
|
| 94 |
+
# directory is set up to be ignored by git, then set
|
| 95 |
+
# GIT_PS1_HIDE_IF_PWD_IGNORED to a nonempty value. Override this on the
|
| 96 |
+
# repository level by setting bash.hideIfPwdIgnored to "false".
|
| 97 |
+
|
| 98 |
+
# check whether printf supports -v
|
| 99 |
+
__git_printf_supports_v=
|
| 100 |
+
printf -v __git_printf_supports_v -- '%s' yes >/dev/null 2>&1
|
| 101 |
+
|
| 102 |
+
# stores the divergence from upstream in $p
|
| 103 |
+
# used by GIT_PS1_SHOWUPSTREAM
|
| 104 |
+
__git_ps1_show_upstream ()
|
| 105 |
+
{
|
| 106 |
+
local key value
|
| 107 |
+
local svn_remote svn_url_pattern count n
|
| 108 |
+
local upstream=git legacy="" verbose="" name=""
|
| 109 |
+
|
| 110 |
+
svn_remote=()
|
| 111 |
+
# get some config options from git-config
|
| 112 |
+
local output="$(git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ')"
|
| 113 |
+
while read -r key value; do
|
| 114 |
+
case "$key" in
|
| 115 |
+
bash.showupstream)
|
| 116 |
+
GIT_PS1_SHOWUPSTREAM="$value"
|
| 117 |
+
if [[ -z "${GIT_PS1_SHOWUPSTREAM}" ]]; then
|
| 118 |
+
p=""
|
| 119 |
+
return
|
| 120 |
+
fi
|
| 121 |
+
;;
|
| 122 |
+
svn-remote.*.url)
|
| 123 |
+
svn_remote[$((${#svn_remote[@]} + 1))]="$value"
|
| 124 |
+
svn_url_pattern="$svn_url_pattern\\|$value"
|
| 125 |
+
upstream=svn+git # default upstream is SVN if available, else git
|
| 126 |
+
;;
|
| 127 |
+
esac
|
| 128 |
+
done <<< "$output"
|
| 129 |
+
|
| 130 |
+
# parse configuration values
|
| 131 |
+
for option in ${GIT_PS1_SHOWUPSTREAM}; do
|
| 132 |
+
case "$option" in
|
| 133 |
+
git|svn) upstream="$option" ;;
|
| 134 |
+
verbose) verbose=1 ;;
|
| 135 |
+
legacy) legacy=1 ;;
|
| 136 |
+
name) name=1 ;;
|
| 137 |
+
esac
|
| 138 |
+
done
|
| 139 |
+
|
| 140 |
+
# Find our upstream
|
| 141 |
+
case "$upstream" in
|
| 142 |
+
git) upstream="@{upstream}" ;;
|
| 143 |
+
svn*)
|
| 144 |
+
# get the upstream from the "git-svn-id: ..." in a commit message
|
| 145 |
+
# (git-svn uses essentially the same procedure internally)
|
| 146 |
+
local -a svn_upstream
|
| 147 |
+
svn_upstream=($(git log --first-parent -1 \
|
| 148 |
+
--grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null))
|
| 149 |
+
if [[ 0 -ne ${#svn_upstream[@]} ]]; then
|
| 150 |
+
svn_upstream=${svn_upstream[${#svn_upstream[@]} - 2]}
|
| 151 |
+
svn_upstream=${svn_upstream%@*}
|
| 152 |
+
local n_stop="${#svn_remote[@]}"
|
| 153 |
+
for ((n=1; n <= n_stop; n++)); do
|
| 154 |
+
svn_upstream=${svn_upstream#${svn_remote[$n]}}
|
| 155 |
+
done
|
| 156 |
+
|
| 157 |
+
if [[ -z "$svn_upstream" ]]; then
|
| 158 |
+
# default branch name for checkouts with no layout:
|
| 159 |
+
upstream=${GIT_SVN_ID:-git-svn}
|
| 160 |
+
else
|
| 161 |
+
upstream=${svn_upstream#/}
|
| 162 |
+
fi
|
| 163 |
+
elif [[ "svn+git" = "$upstream" ]]; then
|
| 164 |
+
upstream="@{upstream}"
|
| 165 |
+
fi
|
| 166 |
+
;;
|
| 167 |
+
esac
|
| 168 |
+
|
| 169 |
+
# Find how many commits we are ahead/behind our upstream
|
| 170 |
+
if [[ -z "$legacy" ]]; then
|
| 171 |
+
count="$(git rev-list --count --left-right \
|
| 172 |
+
"$upstream"...HEAD 2>/dev/null)"
|
| 173 |
+
else
|
| 174 |
+
# produce equivalent output to --count for older versions of git
|
| 175 |
+
local commits
|
| 176 |
+
if commits="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null)"
|
| 177 |
+
then
|
| 178 |
+
local commit behind=0 ahead=0
|
| 179 |
+
for commit in $commits
|
| 180 |
+
do
|
| 181 |
+
case "$commit" in
|
| 182 |
+
"<"*) ((behind++)) ;;
|
| 183 |
+
*) ((ahead++)) ;;
|
| 184 |
+
esac
|
| 185 |
+
done
|
| 186 |
+
count="$behind $ahead"
|
| 187 |
+
else
|
| 188 |
+
count=""
|
| 189 |
+
fi
|
| 190 |
+
fi
|
| 191 |
+
|
| 192 |
+
# calculate the result
|
| 193 |
+
if [[ -z "$verbose" ]]; then
|
| 194 |
+
case "$count" in
|
| 195 |
+
"") # no upstream
|
| 196 |
+
p="" ;;
|
| 197 |
+
"0 0") # equal to upstream
|
| 198 |
+
p="=" ;;
|
| 199 |
+
"0 "*) # ahead of upstream
|
| 200 |
+
p=">" ;;
|
| 201 |
+
*" 0") # behind upstream
|
| 202 |
+
p="<" ;;
|
| 203 |
+
*) # diverged from upstream
|
| 204 |
+
p="<>" ;;
|
| 205 |
+
esac
|
| 206 |
+
else
|
| 207 |
+
case "$count" in
|
| 208 |
+
"") # no upstream
|
| 209 |
+
p="" ;;
|
| 210 |
+
"0 0") # equal to upstream
|
| 211 |
+
p=" u=" ;;
|
| 212 |
+
"0 "*) # ahead of upstream
|
| 213 |
+
p=" u+${count#0 }" ;;
|
| 214 |
+
*" 0") # behind upstream
|
| 215 |
+
p=" u-${count% 0}" ;;
|
| 216 |
+
*) # diverged from upstream
|
| 217 |
+
p=" u+${count#* }-${count% *}" ;;
|
| 218 |
+
esac
|
| 219 |
+
if [[ -n "$count" && -n "$name" ]]; then
|
| 220 |
+
__git_ps1_upstream_name=$(git rev-parse \
|
| 221 |
+
--abbrev-ref "$upstream" 2>/dev/null)
|
| 222 |
+
if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then
|
| 223 |
+
p="$p \${__git_ps1_upstream_name}"
|
| 224 |
+
else
|
| 225 |
+
p="$p ${__git_ps1_upstream_name}"
|
| 226 |
+
# not needed anymore; keep user's
|
| 227 |
+
# environment clean
|
| 228 |
+
unset __git_ps1_upstream_name
|
| 229 |
+
fi
|
| 230 |
+
fi
|
| 231 |
+
fi
|
| 232 |
+
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
# Helper function that is meant to be called from __git_ps1. It
|
| 236 |
+
# injects color codes into the appropriate gitstring variables used
|
| 237 |
+
# to build a gitstring.
|
| 238 |
+
__git_ps1_colorize_gitstring ()
|
| 239 |
+
{
|
| 240 |
+
if [[ -n ${ZSH_VERSION-} ]]; then
|
| 241 |
+
local c_red='%F{red}'
|
| 242 |
+
local c_green='%F{green}'
|
| 243 |
+
local c_lblue='%F{blue}'
|
| 244 |
+
local c_clear='%f'
|
| 245 |
+
else
|
| 246 |
+
# Using \[ and \] around colors is necessary to prevent
|
| 247 |
+
# issues with command line editing/browsing/completion!
|
| 248 |
+
local c_red='\[\e[31m\]'
|
| 249 |
+
local c_green='\[\e[32m\]'
|
| 250 |
+
local c_lblue='\[\e[1;34m\]'
|
| 251 |
+
local c_clear='\[\e[0m\]'
|
| 252 |
+
fi
|
| 253 |
+
local bad_color=$c_red
|
| 254 |
+
local ok_color=$c_green
|
| 255 |
+
local flags_color="$c_lblue"
|
| 256 |
+
|
| 257 |
+
local branch_color=""
|
| 258 |
+
if [ $detached = no ]; then
|
| 259 |
+
branch_color="$ok_color"
|
| 260 |
+
else
|
| 261 |
+
branch_color="$bad_color"
|
| 262 |
+
fi
|
| 263 |
+
c="$branch_color$c"
|
| 264 |
+
|
| 265 |
+
z="$c_clear$z"
|
| 266 |
+
if [ "$w" = "*" ]; then
|
| 267 |
+
w="$bad_color$w"
|
| 268 |
+
fi
|
| 269 |
+
if [ -n "$i" ]; then
|
| 270 |
+
i="$ok_color$i"
|
| 271 |
+
fi
|
| 272 |
+
if [ -n "$s" ]; then
|
| 273 |
+
s="$flags_color$s"
|
| 274 |
+
fi
|
| 275 |
+
if [ -n "$u" ]; then
|
| 276 |
+
u="$bad_color$u"
|
| 277 |
+
fi
|
| 278 |
+
r="$c_clear$r"
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
# Helper function to read the first line of a file into a variable.
|
| 282 |
+
# __git_eread requires 2 arguments, the file path and the name of the
|
| 283 |
+
# variable, in that order.
|
| 284 |
+
__git_eread ()
|
| 285 |
+
{
|
| 286 |
+
test -r "$1" && IFS=$'\r\n' read "$2" <"$1"
|
| 287 |
+
}
|
| 288 |
+
|
| 289 |
+
# see if a cherry-pick or revert is in progress, if the user has committed a
|
| 290 |
+
# conflict resolution with 'git commit' in the middle of a sequence of picks or
|
| 291 |
+
# reverts then CHERRY_PICK_HEAD/REVERT_HEAD will not exist so we have to read
|
| 292 |
+
# the todo file.
|
| 293 |
+
__git_sequencer_status ()
|
| 294 |
+
{
|
| 295 |
+
local todo
|
| 296 |
+
if test -f "$g/CHERRY_PICK_HEAD"
|
| 297 |
+
then
|
| 298 |
+
r="|CHERRY-PICKING"
|
| 299 |
+
return 0;
|
| 300 |
+
elif test -f "$g/REVERT_HEAD"
|
| 301 |
+
then
|
| 302 |
+
r="|REVERTING"
|
| 303 |
+
return 0;
|
| 304 |
+
elif __git_eread "$g/sequencer/todo" todo
|
| 305 |
+
then
|
| 306 |
+
case "$todo" in
|
| 307 |
+
p[\ \ ]|pick[\ \ ]*)
|
| 308 |
+
r="|CHERRY-PICKING"
|
| 309 |
+
return 0
|
| 310 |
+
;;
|
| 311 |
+
revert[\ \ ]*)
|
| 312 |
+
r="|REVERTING"
|
| 313 |
+
return 0
|
| 314 |
+
;;
|
| 315 |
+
esac
|
| 316 |
+
fi
|
| 317 |
+
return 1
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
# __git_ps1 accepts 0 or 1 arguments (i.e., format string)
|
| 321 |
+
# when called from PS1 using command substitution
|
| 322 |
+
# in this mode it prints text to add to bash PS1 prompt (includes branch name)
|
| 323 |
+
#
|
| 324 |
+
# __git_ps1 requires 2 or 3 arguments when called from PROMPT_COMMAND (pc)
|
| 325 |
+
# in that case it _sets_ PS1. The arguments are parts of a PS1 string.
|
| 326 |
+
# when two arguments are given, the first is prepended and the second appended
|
| 327 |
+
# to the state string when assigned to PS1.
|
| 328 |
+
# The optional third parameter will be used as printf format string to further
|
| 329 |
+
# customize the output of the git-status string.
|
| 330 |
+
# In this mode you can request colored hints using GIT_PS1_SHOWCOLORHINTS=true
|
| 331 |
+
__git_ps1 ()
|
| 332 |
+
{
|
| 333 |
+
# preserve exit status
|
| 334 |
+
local exit=$?
|
| 335 |
+
local pcmode=no
|
| 336 |
+
local detached=no
|
| 337 |
+
local ps1pc_start='\u@\h:\w '
|
| 338 |
+
local ps1pc_end='\$ '
|
| 339 |
+
local printf_format=' (%s)'
|
| 340 |
+
|
| 341 |
+
case "$#" in
|
| 342 |
+
2|3) pcmode=yes
|
| 343 |
+
ps1pc_start="$1"
|
| 344 |
+
ps1pc_end="$2"
|
| 345 |
+
printf_format="${3:-$printf_format}"
|
| 346 |
+
# set PS1 to a plain prompt so that we can
|
| 347 |
+
# simply return early if the prompt should not
|
| 348 |
+
# be decorated
|
| 349 |
+
PS1="$ps1pc_start$ps1pc_end"
|
| 350 |
+
;;
|
| 351 |
+
0|1) printf_format="${1:-$printf_format}"
|
| 352 |
+
;;
|
| 353 |
+
*) return $exit
|
| 354 |
+
;;
|
| 355 |
+
esac
|
| 356 |
+
|
| 357 |
+
# ps1_expanded: This variable is set to 'yes' if the shell
|
| 358 |
+
# subjects the value of PS1 to parameter expansion:
|
| 359 |
+
#
|
| 360 |
+
# * bash does unless the promptvars option is disabled
|
| 361 |
+
# * zsh does not unless the PROMPT_SUBST option is set
|
| 362 |
+
# * POSIX shells always do
|
| 363 |
+
#
|
| 364 |
+
# If the shell would expand the contents of PS1 when drawing
|
| 365 |
+
# the prompt, a raw ref name must not be included in PS1.
|
| 366 |
+
# This protects the user from arbitrary code execution via
|
| 367 |
+
# specially crafted ref names. For example, a ref named
|
| 368 |
+
# 'refs/heads/$(IFS=_;cmd=sudo_rm_-rf_/;$cmd)' might cause the
|
| 369 |
+
# shell to execute 'sudo rm -rf /' when the prompt is drawn.
|
| 370 |
+
#
|
| 371 |
+
# Instead, the ref name should be placed in a separate global
|
| 372 |
+
# variable (in the __git_ps1_* namespace to avoid colliding
|
| 373 |
+
# with the user's environment) and that variable should be
|
| 374 |
+
# referenced from PS1. For example:
|
| 375 |
+
#
|
| 376 |
+
# __git_ps1_foo=$(do_something_to_get_ref_name)
|
| 377 |
+
# PS1="...stuff...\${__git_ps1_foo}...stuff..."
|
| 378 |
+
#
|
| 379 |
+
# If the shell does not expand the contents of PS1, the raw
|
| 380 |
+
# ref name must be included in PS1.
|
| 381 |
+
#
|
| 382 |
+
# The value of this variable is only relevant when in pcmode.
|
| 383 |
+
#
|
| 384 |
+
# Assume that the shell follows the POSIX specification and
|
| 385 |
+
# expands PS1 unless determined otherwise. (This is more
|
| 386 |
+
# likely to be correct if the user has a non-bash, non-zsh
|
| 387 |
+
# shell and safer than the alternative if the assumption is
|
| 388 |
+
# incorrect.)
|
| 389 |
+
#
|
| 390 |
+
local ps1_expanded=yes
|
| 391 |
+
[ -z "${ZSH_VERSION-}" ] || [[ -o PROMPT_SUBST ]] || ps1_expanded=no
|
| 392 |
+
[ -z "${BASH_VERSION-}" ] || shopt -q promptvars || ps1_expanded=no
|
| 393 |
+
|
| 394 |
+
local repo_info rev_parse_exit_code
|
| 395 |
+
repo_info="$(git rev-parse --git-dir --is-inside-git-dir \
|
| 396 |
+
--is-bare-repository --is-inside-work-tree \
|
| 397 |
+
--short HEAD 2>/dev/null)"
|
| 398 |
+
rev_parse_exit_code="$?"
|
| 399 |
+
|
| 400 |
+
if [ -z "$repo_info" ]; then
|
| 401 |
+
return $exit
|
| 402 |
+
fi
|
| 403 |
+
|
| 404 |
+
local short_sha=""
|
| 405 |
+
if [ "$rev_parse_exit_code" = "0" ]; then
|
| 406 |
+
short_sha="${repo_info##*$'\n'}"
|
| 407 |
+
repo_info="${repo_info%$'\n'*}"
|
| 408 |
+
fi
|
| 409 |
+
local inside_worktree="${repo_info##*$'\n'}"
|
| 410 |
+
repo_info="${repo_info%$'\n'*}"
|
| 411 |
+
local bare_repo="${repo_info##*$'\n'}"
|
| 412 |
+
repo_info="${repo_info%$'\n'*}"
|
| 413 |
+
local inside_gitdir="${repo_info##*$'\n'}"
|
| 414 |
+
local g="${repo_info%$'\n'*}"
|
| 415 |
+
|
| 416 |
+
if [ "true" = "$inside_worktree" ] &&
|
| 417 |
+
[ -n "${GIT_PS1_HIDE_IF_PWD_IGNORED-}" ] &&
|
| 418 |
+
[ "$(git config --bool bash.hideIfPwdIgnored)" != "false" ] &&
|
| 419 |
+
git check-ignore -q .
|
| 420 |
+
then
|
| 421 |
+
return $exit
|
| 422 |
+
fi
|
| 423 |
+
|
| 424 |
+
local r=""
|
| 425 |
+
local b=""
|
| 426 |
+
local step=""
|
| 427 |
+
local total=""
|
| 428 |
+
if [ -d "$g/rebase-merge" ]; then
|
| 429 |
+
__git_eread "$g/rebase-merge/head-name" b
|
| 430 |
+
__git_eread "$g/rebase-merge/msgnum" step
|
| 431 |
+
__git_eread "$g/rebase-merge/end" total
|
| 432 |
+
r="|REBASE"
|
| 433 |
+
else
|
| 434 |
+
if [ -d "$g/rebase-apply" ]; then
|
| 435 |
+
__git_eread "$g/rebase-apply/next" step
|
| 436 |
+
__git_eread "$g/rebase-apply/last" total
|
| 437 |
+
if [ -f "$g/rebase-apply/rebasing" ]; then
|
| 438 |
+
__git_eread "$g/rebase-apply/head-name" b
|
| 439 |
+
r="|REBASE"
|
| 440 |
+
elif [ -f "$g/rebase-apply/applying" ]; then
|
| 441 |
+
r="|AM"
|
| 442 |
+
else
|
| 443 |
+
r="|AM/REBASE"
|
| 444 |
+
fi
|
| 445 |
+
elif [ -f "$g/MERGE_HEAD" ]; then
|
| 446 |
+
r="|MERGING"
|
| 447 |
+
elif __git_sequencer_status; then
|
| 448 |
+
:
|
| 449 |
+
elif [ -f "$g/BISECT_LOG" ]; then
|
| 450 |
+
r="|BISECTING"
|
| 451 |
+
fi
|
| 452 |
+
|
| 453 |
+
if [ -n "$b" ]; then
|
| 454 |
+
:
|
| 455 |
+
elif [ -h "$g/HEAD" ]; then
|
| 456 |
+
# symlink symbolic ref
|
| 457 |
+
b="$(git symbolic-ref HEAD 2>/dev/null)"
|
| 458 |
+
else
|
| 459 |
+
local head=""
|
| 460 |
+
if ! __git_eread "$g/HEAD" head; then
|
| 461 |
+
return $exit
|
| 462 |
+
fi
|
| 463 |
+
# is it a symbolic ref?
|
| 464 |
+
b="${head#ref: }"
|
| 465 |
+
if [ "$head" = "$b" ]; then
|
| 466 |
+
detached=yes
|
| 467 |
+
b="$(
|
| 468 |
+
case "${GIT_PS1_DESCRIBE_STYLE-}" in
|
| 469 |
+
(contains)
|
| 470 |
+
git describe --contains HEAD ;;
|
| 471 |
+
(branch)
|
| 472 |
+
git describe --contains --all HEAD ;;
|
| 473 |
+
(tag)
|
| 474 |
+
git describe --tags HEAD ;;
|
| 475 |
+
(describe)
|
| 476 |
+
git describe HEAD ;;
|
| 477 |
+
(* | default)
|
| 478 |
+
git describe --tags --exact-match HEAD ;;
|
| 479 |
+
esac 2>/dev/null)" ||
|
| 480 |
+
|
| 481 |
+
b="$short_sha..."
|
| 482 |
+
b="($b)"
|
| 483 |
+
fi
|
| 484 |
+
fi
|
| 485 |
+
fi
|
| 486 |
+
|
| 487 |
+
if [ -n "$step" ] && [ -n "$total" ]; then
|
| 488 |
+
r="$r $step/$total"
|
| 489 |
+
fi
|
| 490 |
+
|
| 491 |
+
local w=""
|
| 492 |
+
local i=""
|
| 493 |
+
local s=""
|
| 494 |
+
local u=""
|
| 495 |
+
local c=""
|
| 496 |
+
local p=""
|
| 497 |
+
|
| 498 |
+
if [ "true" = "$inside_gitdir" ]; then
|
| 499 |
+
if [ "true" = "$bare_repo" ]; then
|
| 500 |
+
c="BARE:"
|
| 501 |
+
else
|
| 502 |
+
b="GIT_DIR!"
|
| 503 |
+
fi
|
| 504 |
+
elif [ "true" = "$inside_worktree" ]; then
|
| 505 |
+
if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ] &&
|
| 506 |
+
[ "$(git config --bool bash.showDirtyState)" != "false" ]
|
| 507 |
+
then
|
| 508 |
+
git diff --no-ext-diff --quiet || w="*"
|
| 509 |
+
git diff --no-ext-diff --cached --quiet || i="+"
|
| 510 |
+
if [ -z "$short_sha" ] && [ -z "$i" ]; then
|
| 511 |
+
i="#"
|
| 512 |
+
fi
|
| 513 |
+
fi
|
| 514 |
+
if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ] &&
|
| 515 |
+
git rev-parse --verify --quiet refs/stash >/dev/null
|
| 516 |
+
then
|
| 517 |
+
s="$"
|
| 518 |
+
fi
|
| 519 |
+
|
| 520 |
+
if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ] &&
|
| 521 |
+
[ "$(git config --bool bash.showUntrackedFiles)" != "false" ] &&
|
| 522 |
+
git ls-files --others --exclude-standard --directory --no-empty-directory --error-unmatch -- ':/*' >/dev/null 2>/dev/null
|
| 523 |
+
then
|
| 524 |
+
u="%${ZSH_VERSION+%}"
|
| 525 |
+
fi
|
| 526 |
+
|
| 527 |
+
if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
|
| 528 |
+
__git_ps1_show_upstream
|
| 529 |
+
fi
|
| 530 |
+
fi
|
| 531 |
+
|
| 532 |
+
local z="${GIT_PS1_STATESEPARATOR-" "}"
|
| 533 |
+
|
| 534 |
+
# NO color option unless in PROMPT_COMMAND mode
|
| 535 |
+
if [ $pcmode = yes ] && [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
|
| 536 |
+
__git_ps1_colorize_gitstring
|
| 537 |
+
fi
|
| 538 |
+
|
| 539 |
+
b=${b##refs/heads/}
|
| 540 |
+
if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then
|
| 541 |
+
__git_ps1_branch_name=$b
|
| 542 |
+
b="\${__git_ps1_branch_name}"
|
| 543 |
+
fi
|
| 544 |
+
|
| 545 |
+
local f="$w$i$s$u"
|
| 546 |
+
local gitstring="$c$b${f:+$z$f}$r$p"
|
| 547 |
+
|
| 548 |
+
if [ $pcmode = yes ]; then
|
| 549 |
+
if [ "${__git_printf_supports_v-}" != yes ]; then
|
| 550 |
+
gitstring=$(printf -- "$printf_format" "$gitstring")
|
| 551 |
+
else
|
| 552 |
+
printf -v gitstring -- "$printf_format" "$gitstring"
|
| 553 |
+
fi
|
| 554 |
+
PS1="$ps1pc_start$gitstring$ps1pc_end"
|
| 555 |
+
else
|
| 556 |
+
printf -- "$printf_format" "$gitstring"
|
| 557 |
+
fi
|
| 558 |
+
|
| 559 |
+
return $exit
|
| 560 |
+
}
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/hooks/post-commit
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
if git status -u no | grep ahead; then
|
| 4 |
+
git push
|
| 5 |
+
fi
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/hooks/post-merge
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# recompile the jtframe utility after a git pull or merge
|
| 4 |
+
|
| 5 |
+
if [ ! -z "$JTFRAME" ]; then
|
| 6 |
+
rm -f $JTFRAME/src/jtframe/jtframe
|
| 7 |
+
$JTFRAME/bin/jtframe
|
| 8 |
+
fi
|
| 9 |
+
exit 0
|
| 10 |
+
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/hooks/pre-commit
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -e
|
| 2 |
+
|
| 3 |
+
# run go tests
|
| 4 |
+
log=`mktemp`
|
| 5 |
+
for program in jtframe jtutil; do
|
| 6 |
+
cd $JTFRAME/src/$program
|
| 7 |
+
echo -n "Go test on $program"
|
| 8 |
+
if ! go test ./... > $log; then
|
| 9 |
+
echo " FAIL"
|
| 10 |
+
cat $log
|
| 11 |
+
rm -f $log
|
| 12 |
+
exit 1
|
| 13 |
+
fi
|
| 14 |
+
echo " PASS"
|
| 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Packages needed on a fresh Ubuntu 20,04 installation
|
| 3 |
+
# Sublime-text isn't really needed for compilation but
|
| 4 |
+
# it is the recommended text editor
|
| 5 |
+
|
| 6 |
+
set -e
|
| 7 |
+
|
| 8 |
+
# Sublime Text
|
| 9 |
+
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/sublimehq-archive.gpg > /dev/null
|
| 10 |
+
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
|
| 11 |
+
|
| 12 |
+
sudo apt update
|
| 13 |
+
sudo apt upgrade --yes
|
| 14 |
+
|
| 15 |
+
sudo apt install --yes --install-suggests apt-transport-https nfs-common
|
| 16 |
+
sudo apt install --yes --install-suggests build-essential git gtkwave figlet xmlstarlet \
|
| 17 |
+
sublime-text
|
| 18 |
+
# repository called docker in ubuntu 20.04, docker.io in ubuntu 24.04
|
| 19 |
+
sudo apt install --yes docker.io
|
| 20 |
+
sudo apt install --yes python-is-python3
|
| 21 |
+
|
| 22 |
+
# required by iverilog
|
| 23 |
+
sudo apt install --yes flex gperf bison
|
| 24 |
+
|
| 25 |
+
# libpng12, required by Quartus 17
|
| 26 |
+
wget https://downloads.sourceforge.net/libpng/libpng-1.2.59.tar.gz
|
| 27 |
+
tar -xvzf libpng-1.2.59.tar.gz
|
| 28 |
+
cd libpng-1.2.59
|
| 29 |
+
./configure
|
| 30 |
+
make
|
| 31 |
+
sudo make install
|
| 32 |
+
|
| 33 |
+
# required by MAME
|
| 34 |
+
sudo apt install --yes libqwt-qt5-dev libsdl2-dev libfontconfig1-dev libsdl2-ttf-dev \
|
| 35 |
+
libfontconfig-dev libpulse-dev qtbase5-dev qtbase5-dev-tools \
|
| 36 |
+
qtchooser qt5-qmake
|
| 37 |
+
|
| 38 |
+
# jtcore and jtupdate
|
| 39 |
+
sudo apt install --yes parallel locate python3-pip fatattr sshpass gawk libxml2-utils
|
| 40 |
+
sudo updatedb
|
| 41 |
+
|
| 42 |
+
# KiCAD
|
| 43 |
+
sudo add-apt-repository ppa:kicad/kicad-8.0-releases
|
| 44 |
+
sudo apt update
|
| 45 |
+
sudo apt install --yes kicad
|
| 46 |
+
|
| 47 |
+
# Locale
|
| 48 |
+
sudo apt install --yes locales locales-all
|
| 49 |
+
sudo locale-gen en_US.UTF-8
|
| 50 |
+
|
| 51 |
+
# open picoblaze assembler needed for assembling the cheat and beta code
|
| 52 |
+
sudo pip install --upgrade opbasm
|
| 53 |
+
|
| 54 |
+
# as31 to compile 8051/8751 assembler code
|
| 55 |
+
sudo apt install --yes as31
|
| 56 |
+
|
| 57 |
+
# asm48 to compile MCS-48 assembler code
|
| 58 |
+
cd /tmp
|
| 59 |
+
git clone https://github.com/jotego/asm48.git
|
| 60 |
+
cd asm48
|
| 61 |
+
make
|
| 62 |
+
sudo cp 8039dasm asm48 /usr/local/bin
|
| 63 |
+
|
| 64 |
+
# macro assembler for many, many CPUs
|
| 65 |
+
cd /tmp
|
| 66 |
+
wget http://john.ccac.rwth-aachen.de:8000/ftp/as/source/c_version/asl-current.tar.gz
|
| 67 |
+
tar xfz asl-current.tar.gz
|
| 68 |
+
cd asl-current
|
| 69 |
+
ln -s Makefile.def-samples/Makefile.def-x86_64-unknown-linux Makefile.def
|
| 70 |
+
make
|
| 71 |
+
sudo cp alink asl p2bin p2hex pbind plist /usr/local/bin
|
| 72 |
+
sudo mkdir -p /usr/local/share/man/man1/
|
| 73 |
+
sudo cp man/* /usr/local/share/man/man1/
|
| 74 |
+
|
| 75 |
+
# MRA tool to generate .arc files
|
| 76 |
+
cd /tmp
|
| 77 |
+
git clone https://github.com/mist-devel/mra-tools-c.git
|
| 78 |
+
cd mra-tools-c
|
| 79 |
+
make -j
|
| 80 |
+
sudo mv mra /usr/local/bin/mra
|
| 81 |
+
|
| 82 |
+
# Verilator
|
| 83 |
+
sudo apt install --yes git help2man perl python3 make autoconf g++ flex bison ccache
|
| 84 |
+
sudo apt install --yes libgoogle-perftools-dev numactl perl-doc
|
| 85 |
+
# Ubuntu only (ignore if alrea error)
|
| 86 |
+
sudo apt install --yes libfl2 libfl-dev zlib1g zlib1g-dev
|
| 87 |
+
|
| 88 |
+
cd $HOME
|
| 89 |
+
unset VERILATOR_ROOT
|
| 90 |
+
git clone https://github.com/verilator/verilator.git --depth 1 || exit $?
|
| 91 |
+
cd $HOME/verilator
|
| 92 |
+
autoconf
|
| 93 |
+
./configure
|
| 94 |
+
# compile using 80% of available CPUs
|
| 95 |
+
make -j $((`nproc`*4/5))
|
| 96 |
+
export VERILATOR_ROOT=`pwd`
|
| 97 |
+
echo export VERILATOR_ROOT=`pwd` >> $HOME/.bashrc
|
| 98 |
+
|
| 99 |
+
# Icarus Verilog
|
| 100 |
+
git clone https://github.com/steveicarus/iverilog.git
|
| 101 |
+
cd iverilog
|
| 102 |
+
git checkout v12_0
|
| 103 |
+
sh autoconf.sh
|
| 104 |
+
./configure
|
| 105 |
+
make -j $((`nproc`*4/5))
|
| 106 |
+
sudo make install
|
| 107 |
+
|
| 108 |
+
# nice to have
|
| 109 |
+
sudo apt install --yes htop flameshot ghex
|
| 110 |
+
|
| 111 |
+
# git configuration
|
| 112 |
+
git config --global url.ssh://git@github.com/.insteadOf https://github.com/
|
| 113 |
+
git config --global alias.d diff
|
| 114 |
+
git config --global alias.co checkout
|
| 115 |
+
git config --global alias.st status
|
| 116 |
+
git config --global alias.wt worktree
|
| 117 |
+
git config --global alias.p pull
|
| 118 |
+
git config --global alias.b bisect
|
| 119 |
+
git config --global alias.su "submodule update"
|
| 120 |
+
git config --global alias.r "reset --hard"
|
| 121 |
+
# handling of EOL characters
|
| 122 |
+
git config --global core.whitespace cr-at-eol
|
| 123 |
+
git config --global core.autocrlf input
|
| 124 |
+
# aim for a linear history
|
| 125 |
+
git config --global pull.rebase true
|
| 126 |
+
|
| 127 |
+
# Go
|
| 128 |
+
GONAME=go1.21.3.linux-amd64.tar.gz
|
| 129 |
+
wget https://go.dev/dl/$GONAME
|
| 130 |
+
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf $GONAME
|
| 131 |
+
sudo rm -f $GONAME
|
| 132 |
+
export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin
|
| 133 |
+
echo export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin >> $HOME/.bashrc
|
| 134 |
+
go install github.com/spf13/cobra-cli@latest
|
| 135 |
+
go install golang.org/x/tools/cmd/goimports@latest
|
| 136 |
+
go install golang.org/x/tools/cmd/godoc@latest
|
| 137 |
+
|
| 138 |
+
# GitHub CLI
|
| 139 |
+
type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y)
|
| 140 |
+
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
|
| 141 |
+
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
|
| 142 |
+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
|
| 143 |
+
&& sudo apt update \
|
| 144 |
+
&& sudo apt install gh -y
|
| 145 |
+
|
| 146 |
+
# Set up repositories
|
| 147 |
+
cat<<EOF
|
| 148 |
+
Run these commands after setting the SSH key in GitHub
|
| 149 |
+
|
| 150 |
+
cd $HOME
|
| 151 |
+
git clone --recurse-submodules git@github.com:jotego/jtcores.git
|
| 152 |
+
mkdir jtmisc
|
| 153 |
+
cd jtmisc
|
| 154 |
+
git clone --depth 1 --shallow-since="$(date --date='-2 weeks' +%F)" git@github.com:jotego/jtbin.git
|
| 155 |
+
git clone git@github.com:jotego/jtbeta.git
|
| 156 |
+
git clone git@github.com:JTFPGA/jtutil.git
|
| 157 |
+
EOF
|
| 158 |
+
|
| 159 |
+
# USB Blaster
|
| 160 |
+
jtblaster
|
| 161 |
+
|
| 162 |
+
# audio play and visualization
|
| 163 |
+
sudo apt install mplayer audacity
|
| 164 |
+
|
| 165 |
+
# Cross-Compiler
|
| 166 |
+
# m68k-linux-gnu-gcc
|
| 167 |
+
sudo apt install gcc-m68k-linux-gnu
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/install/quartus13_20.04.sh
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# This will set up the libraries required to run Quartus 13 on Ubuntu 20.04
|
| 3 |
+
# Quartus 13.1 should be already installed at /opt/altera/13.1
|
| 4 |
+
# Run with sudo
|
| 5 |
+
|
| 6 |
+
# Get
|
| 7 |
+
dpkg --add-architecture i386
|
| 8 |
+
apt update
|
| 9 |
+
apt install make:i386 libxdmcp6:i386 libxau6:i386 libxext6:i386 libxft-dev:i386 \
|
| 10 |
+
libxft2:i386 libxrender1:i386 libxt6:i386 libfontconfig1-dev:i386 \
|
| 11 |
+
libxtst6:i386 libx11-6:i386 unixodbc:i386 libzmq3-dev:i386 \
|
| 12 |
+
libxext6:i386 libxi6:i386
|
| 13 |
+
# Missing ncurses-base:i386
|
| 14 |
+
|
| 15 |
+
DIR=`mktemp --directory`
|
| 16 |
+
cd $DIR
|
| 17 |
+
wget http://se.archive.ubuntu.com/ubuntu/pool/main/libp/libpng/libpng12-0_1.2.54-1ubuntu1_i386.deb
|
| 18 |
+
DIR2=`mktemp --directory`
|
| 19 |
+
dpkg -x libpng12-0_1.2.54-1ubuntu1_i386.deb $DIR2
|
| 20 |
+
cp $DIR2/lib/i386-linux-gnu/* /usr/lib32
|
| 21 |
+
|
| 22 |
+
# Create a script to run quartus13
|
| 23 |
+
cat > /usr/bin/q13 <<EOF
|
| 24 |
+
#!/bin/bash
|
| 25 |
+
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:.
|
| 26 |
+
PATH=$PATH:/opt/altera/13.1/quartus/bin:/opt/altera/13.1/quartus/linux
|
| 27 |
+
export PATH
|
| 28 |
+
quartus
|
| 29 |
+
EOF
|
| 30 |
+
chmod +x /usr/bin/q13
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtbeta
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -e
|
| 2 |
+
# This file is part of JTFRAME.
|
| 3 |
+
# JTFRAME program is free software: you can redistribute it and/or modify
|
| 4 |
+
# it under the terms of the GNU General Public License as published by
|
| 5 |
+
# the Free Software Foundation, either version 3 of the License, or
|
| 6 |
+
# (at your option) any later version.
|
| 7 |
+
|
| 8 |
+
# JTFRAME program is distributed in the hope that it will be useful,
|
| 9 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 10 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 11 |
+
# GNU General Public License for more details.
|
| 12 |
+
|
| 13 |
+
# You should have received a copy of the GNU General Public License
|
| 14 |
+
# along with JTFRAME. If not, see <http://www.gnu.org/licenses/>.
|
| 15 |
+
|
| 16 |
+
# Author: Jose Tejada Gomez. Twitter: @topapate
|
| 17 |
+
# Version: 2.0
|
| 18 |
+
# Date: 15-5-2024
|
| 19 |
+
|
| 20 |
+
main() {
|
| 21 |
+
check_folder JTUTIL
|
| 22 |
+
check_folder JTROOT
|
| 23 |
+
local JTBETA=`realpath $JTUTIL/../jtbeta`
|
| 24 |
+
check_folder JTBETA
|
| 25 |
+
make_new_key
|
| 26 |
+
upload_to_jtcores
|
| 27 |
+
upload_to_jtbeta $JTBETA
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
check_folder() {
|
| 31 |
+
env_var_name="$1"
|
| 32 |
+
local folder=`echo \\$$env_var_name | envsubst`
|
| 33 |
+
echo $folder
|
| 34 |
+
if [[ -z "$folder" || ! -d "$folder" ]]; then
|
| 35 |
+
echo "\$$env_var_name must point to a valid folder"
|
| 36 |
+
return 1
|
| 37 |
+
fi
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
make_new_key() {
|
| 41 |
+
cd $JTUTIL
|
| 42 |
+
git pull
|
| 43 |
+
BETAKEY=$(printf "%04X%04X" $RANDOM $RANDOM)
|
| 44 |
+
echo -n $BETAKEY | xxd -r -p > beta.bin
|
| 45 |
+
zip jtbeta.zip beta.bin
|
| 46 |
+
echo "Beta key updated in \$JTUTIL"
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
upload_to_jtcores() {
|
| 50 |
+
cd $JTROOT
|
| 51 |
+
if which gh > /dev/null; then
|
| 52 |
+
gh secret set BETAKEY -b $BETAKEY
|
| 53 |
+
else
|
| 54 |
+
echo "Warning: GitHub BETAKEY secret not updated"
|
| 55 |
+
echo "Install github CLI for automatic update of GitHub secrets"
|
| 56 |
+
fi
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
upload_to_jtbeta() {
|
| 60 |
+
jtbeta="$1"
|
| 61 |
+
cd $jtbeta
|
| 62 |
+
git pull
|
| 63 |
+
cp $JTUTIL/jtbeta.zip .
|
| 64 |
+
git add jtbeta.zip
|
| 65 |
+
git commit -m "new beta key"
|
| 66 |
+
git push
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
main $*
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtbin2mr
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -e
|
| 2 |
+
# Copies the contents of JTBIN to a test folder
|
| 3 |
+
# in MiSTer
|
| 4 |
+
|
| 5 |
+
function show_help {
|
| 6 |
+
cat<<HELP
|
| 7 |
+
JTFRAME (c) Jose Tejada 2023
|
| 8 |
+
|
| 9 |
+
Copies the contents of JTBIN or the release folder to
|
| 10 |
+
a MiSTer device in the network.
|
| 11 |
+
|
| 12 |
+
If called with a git hash, extracts the contents of
|
| 13 |
+
\$JTBUILDS/hash.zip to \$JTROOT/release first and then
|
| 14 |
+
copies it to MiSTer.
|
| 15 |
+
|
| 16 |
+
Usage:
|
| 17 |
+
|
| 18 |
+
jtbin2mr [build hash]
|
| 19 |
+
|
| 20 |
+
-m, --mr MiSTer host name or IP address
|
| 21 |
+
-g, --git Uses JTBIN as the source folder, rather than \$JTROOT/release
|
| 22 |
+
-h, --help Help
|
| 23 |
+
-v, --verbose
|
| 24 |
+
HELP
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
LOCAL=1
|
| 28 |
+
V=
|
| 29 |
+
BUILD=
|
| 30 |
+
|
| 31 |
+
if [ -z "$JTROOT" ]; then
|
| 32 |
+
echo "JTROOT is undefined"
|
| 33 |
+
exit 1
|
| 34 |
+
fi
|
| 35 |
+
|
| 36 |
+
while [ $# -gt 0 ]; do
|
| 37 |
+
case "$1" in
|
| 38 |
+
-g|--git)
|
| 39 |
+
LOCAL=0;; # JTBIN will not be modified
|
| 40 |
+
-m|--mr)
|
| 41 |
+
shift
|
| 42 |
+
export MRHOST=$1;;
|
| 43 |
+
-v|--verbose)
|
| 44 |
+
V=-v;;
|
| 45 |
+
-h|--help)
|
| 46 |
+
show_help
|
| 47 |
+
exit 1;;
|
| 48 |
+
*)
|
| 49 |
+
HASH=`git rev-parse --short $1`
|
| 50 |
+
HASH=${HASH:0:7}
|
| 51 |
+
BUILD="$JTBUILDS/${HASH}.zip"
|
| 52 |
+
if [ ! -e "$BUILD" ]; then
|
| 53 |
+
echo "Cannot find $BUILD"
|
| 54 |
+
echo "Unknown argument $1"
|
| 55 |
+
exit 1
|
| 56 |
+
fi;;
|
| 57 |
+
esac
|
| 58 |
+
shift
|
| 59 |
+
done
|
| 60 |
+
|
| 61 |
+
if [ ! -z "$BUILD" ]; then
|
| 62 |
+
rm -rf $JTROOT/release
|
| 63 |
+
if unzip -l $BUILD | grep '\brelease/' > /dev/null; then
|
| 64 |
+
unzip -q $BUILD -d $JTROOT
|
| 65 |
+
else
|
| 66 |
+
mkdir $JTROOT/release
|
| 67 |
+
unzip -q $BUILD -d $JTROOT/release
|
| 68 |
+
fi
|
| 69 |
+
fi
|
| 70 |
+
|
| 71 |
+
if pwd | grep "$JTBIN"; then
|
| 72 |
+
echo "Copying from JTBIN as the current working dir is JTBIN"
|
| 73 |
+
elif [ $LOCAL = 1 ]; then
|
| 74 |
+
export JTBIN=$JTROOT/release
|
| 75 |
+
fi
|
| 76 |
+
|
| 77 |
+
if [ -z "$MISTERPASSWD" ]; then
|
| 78 |
+
echo "Define the MiSTer password in the environment variable MISTERPASSWD"
|
| 79 |
+
exit 1
|
| 80 |
+
fi
|
| 81 |
+
|
| 82 |
+
if [ -z "$MRHOST" ]; then
|
| 83 |
+
MRHOST=mister.home
|
| 84 |
+
fi
|
| 85 |
+
|
| 86 |
+
if [ -z "$MRUSER" ]; then
|
| 87 |
+
MRUSER=root
|
| 88 |
+
fi
|
| 89 |
+
|
| 90 |
+
########################################################
|
| 91 |
+
if [ "$V" = -v ]; then echo "Gathering the files from $JTBIN"; fi
|
| 92 |
+
TEMP=`mktemp --directory`
|
| 93 |
+
ROOT=$TEMP/_JTBIN
|
| 94 |
+
CORES=$ROOT/cores
|
| 95 |
+
|
| 96 |
+
mkdir -p $CORES
|
| 97 |
+
|
| 98 |
+
if [ -d $JTBIN/mister ]; then
|
| 99 |
+
cp $JTBIN/mister/*.rbf $CORES
|
| 100 |
+
fi
|
| 101 |
+
|
| 102 |
+
cp -r $JTBIN/mra/* $ROOT
|
| 103 |
+
if [ -d $JTBIN/games ]; then cp -r $JTBIN/games $ROOT; fi
|
| 104 |
+
|
| 105 |
+
# Copy the files to MiSTer
|
| 106 |
+
if [ ! -z "$V" ]; then echo -e "\nCopying the files to MiSTer"; fi
|
| 107 |
+
if [ -d /media/$USER/MiSTer_Data ]; then
|
| 108 |
+
echo "MiSTer SD card detected"
|
| 109 |
+
rm -rf /media/$USER/MiSTer_Data/_JTBIN
|
| 110 |
+
cp -r $TEMP/_JTBIN /media/$USER/MiSTer_Data || echo "Copy to MiSTer SD card failed"
|
| 111 |
+
if [ -e $JTUTIL/jtbeta.zip ]; then
|
| 112 |
+
cp $JTUTIL/jtbeta.zip /media/$USER/MiSTer_Data/games/mame
|
| 113 |
+
fi
|
| 114 |
+
elif ping -c 1 -q $MRHOST > /dev/null; then
|
| 115 |
+
MRCMD="sshpass -p $MISTERPASSWD ssh -l $MRUSER $MRHOST"
|
| 116 |
+
$MRCMD "rm -rf /media/fat/_JTBIN"
|
| 117 |
+
$MRCMD "rm -rf /media/fat/config/*.{cfg,CFG}"
|
| 118 |
+
$MRCMD "rm -rf /media/fat/config/nvram/*.nvm"
|
| 119 |
+
$MRCMD "rm -rf /media/fat/config/dips/*"
|
| 120 |
+
if sshpass -p $MISTERPASSWD scp -r $TEMP/* $MRUSER@${MRHOST}:/media/fat; then
|
| 121 |
+
if [ -e $JTBIN/mister/neogeopocket.rbf ]; then
|
| 122 |
+
$MRCMD "cp /media/fat/_JTBIN/cores/neogeopocket.rbf /media/fat/_Console/NeoGeoPocket.rbf"
|
| 123 |
+
fi
|
| 124 |
+
rm -rf $TEMP
|
| 125 |
+
else
|
| 126 |
+
echo "Copy to MiSTer failed. Temporary files in " $TEMP
|
| 127 |
+
exit 1
|
| 128 |
+
fi
|
| 129 |
+
if [ -e $JTUTIL/jtbeta.zip ]; then
|
| 130 |
+
sshpass -p $MISTERPASSWD scp -r $JTUTIL/jtbeta.zip $MRUSER@${MRHOST}:/media/fat/games/mame
|
| 131 |
+
else
|
| 132 |
+
echo "Skipping jtbeta.zip copy"
|
| 133 |
+
fi
|
| 134 |
+
else
|
| 135 |
+
echo "$MRHOST is not online"
|
| 136 |
+
fi
|
| 137 |
+
rm -rf $TEMP
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtbin2sd
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Copies the contents of JTBIN to the SD card
|
| 3 |
+
|
| 4 |
+
function show_help {
|
| 5 |
+
cat<<HELP
|
| 6 |
+
JTFRAME (c) Jose Tejada 2023
|
| 7 |
+
|
| 8 |
+
Copies the contents of JTBIN or the release folder to
|
| 9 |
+
a SD card with the name of the target device.
|
| 10 |
+
|
| 11 |
+
Usage:
|
| 12 |
+
|
| 13 |
+
jtbin2sd.sh [setname] [-l|--local]
|
| 14 |
+
|
| 15 |
+
Optionally indicate the setname to be used as the game to load on power up (core.arc file)
|
| 16 |
+
|
| 17 |
+
-a, --all Regenerate all .rom files (including alternates)
|
| 18 |
+
-g, --git Uses JTBIN as the target folder
|
| 19 |
+
-r, --rom Runs "jtframe mra" for each mra file found to get the main .rom files generated
|
| 20 |
+
-v, --verbose
|
| 21 |
+
HELP
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
LOCAL=1
|
| 25 |
+
V=
|
| 26 |
+
CNT=0
|
| 27 |
+
SETNAME=
|
| 28 |
+
RUNMRA=
|
| 29 |
+
MAINONLY=--mainonly
|
| 30 |
+
|
| 31 |
+
while [ $# -gt 0 ]; do
|
| 32 |
+
case "$1" in
|
| 33 |
+
-g|--git)
|
| 34 |
+
LOCAL=0;; # JTBIN will not be modified
|
| 35 |
+
-r|--rom)
|
| 36 |
+
RUNMRA=1;;
|
| 37 |
+
-a|--all)
|
| 38 |
+
RUNMRA=1
|
| 39 |
+
MAINONLY=;;
|
| 40 |
+
-v|--verbose)
|
| 41 |
+
V=-v;;
|
| 42 |
+
-h|--help)
|
| 43 |
+
show_help
|
| 44 |
+
exit 1;;
|
| 45 |
+
*)
|
| 46 |
+
if [[ "$1" = -* ]]; then
|
| 47 |
+
echo "Unknown argument $1"
|
| 48 |
+
exit 1
|
| 49 |
+
fi
|
| 50 |
+
if [ -z "$SETNAME" ]; then
|
| 51 |
+
SETNAME=$1
|
| 52 |
+
else
|
| 53 |
+
echo "Unknown argument $1"
|
| 54 |
+
echo "Setname was already set to $SETNAME"
|
| 55 |
+
exit 1
|
| 56 |
+
fi;;
|
| 57 |
+
esac
|
| 58 |
+
shift
|
| 59 |
+
done
|
| 60 |
+
|
| 61 |
+
if pwd | grep "$JTBIN"; then
|
| 62 |
+
echo "Copying from JTBIN as the current working dir is JTBIN"
|
| 63 |
+
elif [ $LOCAL = 1 ]; then
|
| 64 |
+
export JTBIN=$JTROOT/release
|
| 65 |
+
fi
|
| 66 |
+
|
| 67 |
+
cd $JTBIN/mra
|
| 68 |
+
|
| 69 |
+
function cp_mist {
|
| 70 |
+
cp $V $JTBIN/$1/*rbf $DST
|
| 71 |
+
# Get the main MRA as the core's arc for JTAG programming
|
| 72 |
+
for CORE in $JTBIN/$1/*rbf; do
|
| 73 |
+
CORE=`basename $CORE .rbf`
|
| 74 |
+
IFS=$'\n'
|
| 75 |
+
for MRA in `find -name "*mra" -print0 | xargs -0 grep --files-with-matches --ignore-case $CORE`; do
|
| 76 |
+
mra -z $HOME/.mame/roms -O $DST -A -s "$MRA"
|
| 77 |
+
done
|
| 78 |
+
unset IFS
|
| 79 |
+
done
|
| 80 |
+
# Set one game as core.arc
|
| 81 |
+
if [ ! -z "$SETNAME" ]; then
|
| 82 |
+
local MAINSET=`grep -iw $SETNAME $DST/*.arc --files-with-matches | head -n 1`
|
| 83 |
+
if [ ! -z "$MAINSET" ]; then
|
| 84 |
+
cp "$MAINSET" $DST/core.arc
|
| 85 |
+
else
|
| 86 |
+
echo "Cannot find any arc file for $SETNAME"
|
| 87 |
+
fi
|
| 88 |
+
elif [ ! -e $DST/core.arc ]; then
|
| 89 |
+
cp -v "`ls $DST/*arc|head -n 1`" $DST/core.arc;
|
| 90 |
+
fi
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
if [ -n "$RUNMRA" ]; then
|
| 94 |
+
RBF=`find $JTBIN/mra -name "*.mra" -print0 | xargs -0 -I_ xmllint --xpath '//rbf/text()' _ | sort | uniq | sed s/^jt//`
|
| 95 |
+
jtframe mra $RBF $MAINONLY
|
| 96 |
+
fi
|
| 97 |
+
|
| 98 |
+
for i in SIDI128 SIDI MIST POCKET; do
|
| 99 |
+
DST=/media/$USER/${i^^}
|
| 100 |
+
if [ ! -d $DST ]; then
|
| 101 |
+
continue
|
| 102 |
+
fi
|
| 103 |
+
echo "`basename $DST` found"
|
| 104 |
+
rm -rf $DST/*
|
| 105 |
+
# Copy RBF and ARC/JSON files
|
| 106 |
+
if [ $i = POCKET ]; then
|
| 107 |
+
cp -r $V $JTBIN/pocket/raw/* $DST
|
| 108 |
+
else
|
| 109 |
+
cp_mist ${i,,} &
|
| 110 |
+
fi
|
| 111 |
+
wait
|
| 112 |
+
# Copy ROM files
|
| 113 |
+
if [ -d $ROM ]; then
|
| 114 |
+
if [ $i = POCKET ]; then
|
| 115 |
+
cd $ROM
|
| 116 |
+
# Copy Pocket assets
|
| 117 |
+
for k in $ROM/cp_*sh; do
|
| 118 |
+
if [ ! -z "$V" ]; then
|
| 119 |
+
echo $k $ROM
|
| 120 |
+
fi
|
| 121 |
+
$k $ROM
|
| 122 |
+
done
|
| 123 |
+
else
|
| 124 |
+
# only copy .rom files for which there is an ARC file
|
| 125 |
+
# convert .RAM file names to uppercase when copying
|
| 126 |
+
find $DST -name "*.arc" -print0 | xargs -0 grep -ho NAME=".*" | \
|
| 127 |
+
(while IFS= read -r LINE; do \
|
| 128 |
+
LINE=${LINE:5}; FN=$ROM/${LINE,,}.rom; \
|
| 129 |
+
if [ -e "$FN" ]; then cp "$FN" $DST; fi; \
|
| 130 |
+
FN=$ROM/${LINE^^}.RAM; \
|
| 131 |
+
if [ -e "$FN" ]; then cp "$FN" $DST; fi \
|
| 132 |
+
done)
|
| 133 |
+
fi
|
| 134 |
+
else
|
| 135 |
+
echo "Skipping ROMs (no ROM folder)"
|
| 136 |
+
fi
|
| 137 |
+
CNT=$((CNT+1))
|
| 138 |
+
done
|
| 139 |
+
|
| 140 |
+
if [ $CNT = 0 ]; then
|
| 141 |
+
echo "Nothing done"
|
| 142 |
+
fi
|
| 143 |
+
|
| 144 |
+
# copy the beta file to the Pocket
|
| 145 |
+
if [[ -d /media/$USER/POCKET && -e $JTUTIL/beta.bin ]]; then
|
| 146 |
+
mkdir -p /media/$USER/POCKET/Assets/jtpatreon/common
|
| 147 |
+
for i in /media/$USER/POCKET/Assets/*; do
|
| 148 |
+
if [ -d $i/common ]; then
|
| 149 |
+
cp $JTUTIL/beta.bin -d $i/common
|
| 150 |
+
fi
|
| 151 |
+
done
|
| 152 |
+
fi
|
| 153 |
+
|
| 154 |
+
# warn for missing rbf_r in the Pocket
|
| 155 |
+
if [ -d /media/$USER/POCKET ]; then
|
| 156 |
+
for i in /media/$USER/POCKET/Cores/*; do
|
| 157 |
+
if [ ! -e $i/*.rbf_r ]; then
|
| 158 |
+
CORENAME=`basename $i`
|
| 159 |
+
CORENAME=${CORENAME#jotego.jt}
|
| 160 |
+
echo "POCKET: no rbf_r for $CORENAME"
|
| 161 |
+
fi
|
| 162 |
+
done
|
| 163 |
+
fi
|
| 164 |
+
|
| 165 |
+
# Make it a bit nicer for MiST systems
|
| 166 |
+
for i in MIST SIDI SIDI128; do
|
| 167 |
+
if [ ! -d /media/$USER/$i ]; then continue; fi
|
| 168 |
+
# Hide RBF files, boots only from ARC files
|
| 169 |
+
fatattr +h /media/$USER/$i/*.rbf
|
| 170 |
+
# Mapping for 8BitDo M30gyu
|
| 171 |
+
cat > /media/$USER/$i/MIST.INI <<EOF
|
| 172 |
+
[MIST]
|
| 173 |
+
USB_STORAGE=1
|
| 174 |
+
JOYSTICK_REMAP="0CA3,0024,1,2,4,8,100,20,10,80,200,40,1000,800,0,400,0,0"
|
| 175 |
+
SCANDOUBLER_DISABLE=0
|
| 176 |
+
EOF
|
| 177 |
+
done
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtblaster
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# This tool prepares an Ubuntu system to work with
|
| 4 |
+
# USB blaster cables
|
| 5 |
+
|
| 6 |
+
if [ $USER != root ]; then
|
| 7 |
+
echo ERROR: You must execute this script as root
|
| 8 |
+
exit 1
|
| 9 |
+
fi
|
| 10 |
+
|
| 11 |
+
cat > /etc/udev/rules.d/51-usbblaster.rules <<FIN
|
| 12 |
+
# USB-Blaster
|
| 13 |
+
BUS=="usb", SYSFS{idVendor}=="09fb", SYSFS{idProduct}=="6001", MODE="0666"
|
| 14 |
+
BUS=="usb", SYSFS{idVendor}=="09fb", SYSFS{idProduct}=="6002", MODE="0666"
|
| 15 |
+
BUS=="usb", SYSFS{idVendor}=="09fb", SYSFS{idProduct}=="6003", MODE="0666"
|
| 16 |
+
|
| 17 |
+
# USB-Blaster II
|
| 18 |
+
BUS=="usb", SYSFS{idVendor}=="09fb", SYSFS{idProduct}=="6010", MODE="0666"
|
| 19 |
+
BUS=="usb", SYSFS{idVendor}=="09fb", SYSFS{idProduct}=="6810", MODE="0666"
|
| 20 |
+
FIN
|
| 21 |
+
|
| 22 |
+
cat > /etc/udev/rules.d/92-usbblaster.rules <<FIN
|
| 23 |
+
# USB-Blaster
|
| 24 |
+
SUBSYSTEM=="usb", ATTR{idVendor}=="09fb", ATTR{idProduct}=="6001", MODE="0666"
|
| 25 |
+
SUBSYSTEM=="usb", ATTR{idVendor}=="09fb", ATTR{idProduct}=="6002", MODE="0666"
|
| 26 |
+
SUBSYSTEM=="usb", ATTR{idVendor}=="09fb", ATTR{idProduct}=="6003", MODE="0666"
|
| 27 |
+
|
| 28 |
+
# USB-Blaster II
|
| 29 |
+
SUBSYSTEM=="usb", ATTR{idVendor}=="09fb", ATTR{idProduct}=="6010", MODE="666"
|
| 30 |
+
SUBSYSTEM=="usb", ATTR{idVendor}=="09fb", ATTR{idProduct}=="6810", MODE="666"
|
| 31 |
+
FIN
|
| 32 |
+
|
| 33 |
+
udevadm control --reload
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtcore
ADDED
|
@@ -0,0 +1,408 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# This file is part of JTFRAME.
|
| 3 |
+
# JTFRAME program is free software: you can redistribute it and/or modify
|
| 4 |
+
# it under the terms of the GNU General Public License as published by
|
| 5 |
+
# the Free Software Foundation, either version 3 of the License, or
|
| 6 |
+
# (at your option) any later version.
|
| 7 |
+
|
| 8 |
+
# JTFRAME program is distributed in the hope that it will be useful,
|
| 9 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 10 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 11 |
+
# GNU General Public License for more details.
|
| 12 |
+
|
| 13 |
+
# You should have received a copy of the GNU General Public License
|
| 14 |
+
# along with JTFRAME. If not, see <http://www.gnu.org/licenses/>.
|
| 15 |
+
|
| 16 |
+
# Author: Jose Tejada Gomez. Twitter: @topapate
|
| 17 |
+
# Version: 1.0
|
| 18 |
+
# Date: 7-7-2022
|
| 19 |
+
|
| 20 |
+
source $JTFRAME/bin/jtcore-funcs
|
| 21 |
+
|
| 22 |
+
CORESTAMP=$(date +"%Y%m%d")
|
| 23 |
+
EXT=rbf
|
| 24 |
+
FAIL=0
|
| 25 |
+
JTBIN2SD=
|
| 26 |
+
MACROS=
|
| 27 |
+
OUTPUTDIR=output_files
|
| 28 |
+
PRJ=
|
| 29 |
+
NODBG=
|
| 30 |
+
NOLINTER=
|
| 31 |
+
PROG=FALSE
|
| 32 |
+
SEED=1
|
| 33 |
+
SKIPTIMING=
|
| 34 |
+
SIM=FALSE
|
| 35 |
+
SKIP_COMPILE=FALSE
|
| 36 |
+
UNMACROS=
|
| 37 |
+
|
| 38 |
+
# use setprj.sh's target function to
|
| 39 |
+
# change the current default target
|
| 40 |
+
if [ -z "$TARGET" ]; then
|
| 41 |
+
TARGET=mist
|
| 42 |
+
fi
|
| 43 |
+
|
| 44 |
+
# Device names for JTAG programming
|
| 45 |
+
# Only MiST programming is fully implemented
|
| 46 |
+
DEVICE_MIST=EP3C25E144
|
| 47 |
+
DEVICE_POCKET=5CEBA4F23C8
|
| 48 |
+
DEVICE=$DEVICE_MIST
|
| 49 |
+
|
| 50 |
+
# Define colours if running on a terminal
|
| 51 |
+
if [ -t 1 ]; then
|
| 52 |
+
red=`tput setaf 1`
|
| 53 |
+
green=`tput setaf 2`
|
| 54 |
+
blue=`tput setaf 4`
|
| 55 |
+
white=`tput setaf 7`
|
| 56 |
+
rBG=`tput setab 1; tput setaf 7`
|
| 57 |
+
gBG=`tput setab 2; tput setaf 7`
|
| 58 |
+
bBG=`tput setab 4; tput setaf 7`
|
| 59 |
+
yBG=`tput setab 3; tput setaf 7`
|
| 60 |
+
wBG=`tput setab 7; tput setaf 0`
|
| 61 |
+
NC=`tput sgr0`
|
| 62 |
+
fi
|
| 63 |
+
|
| 64 |
+
parse_args $JTCORE_DEFAULT
|
| 65 |
+
parse_args $*
|
| 66 |
+
|
| 67 |
+
# Is the root folder environment variable set?
|
| 68 |
+
|
| 69 |
+
if [ "$JTROOT" = "" ]; then
|
| 70 |
+
cd ${0%%modules/jtframe/bin/jtcore}
|
| 71 |
+
if [ -e setprj.sh ]; then
|
| 72 |
+
source setprj.sh --quiet
|
| 73 |
+
else
|
| 74 |
+
echo -e "${yBG}WARNING:${NC}${wBG} cannot find setprj.sh in ${red}$(pwd)${NC}"
|
| 75 |
+
exit 1
|
| 76 |
+
fi
|
| 77 |
+
fi
|
| 78 |
+
|
| 79 |
+
if [ "$JTROOT" = "" ]; then
|
| 80 |
+
echo -e "${rBG}ERROR:${NC}${wBG} Missing JTROOT environment variable.${NC}"
|
| 81 |
+
echo -e " ${wBG}Source JTFRAME/bin/setprj.sh in bash before compiling.${NC}"
|
| 82 |
+
exit 1
|
| 83 |
+
fi
|
| 84 |
+
|
| 85 |
+
if [ -e $JTROOT/.jtcore ]; then source $JTROOT/.jtcore; fi
|
| 86 |
+
|
| 87 |
+
# Is the project defined?
|
| 88 |
+
if [ -z "$PRJ" ]; then
|
| 89 |
+
PRJ=`get_corename_from_folder`
|
| 90 |
+
fi
|
| 91 |
+
|
| 92 |
+
cd $JTROOT
|
| 93 |
+
MODULES=$JTROOT/modules
|
| 94 |
+
JTFRAME=$MODULES/jtframe
|
| 95 |
+
|
| 96 |
+
if [ ! -e "$JTFRAME" ]; then
|
| 97 |
+
echo -e "${rBG}ERROR:${NC}${wBG} cannot locate jtframe folder.${NC}"
|
| 98 |
+
echo -e " ${wBG} It should be at ${red}$JTFRAME${NC}"
|
| 99 |
+
exit 1
|
| 100 |
+
fi
|
| 101 |
+
|
| 102 |
+
if [ ${PRJ:0:1} = - ]; then
|
| 103 |
+
echo -e "${rBG}ERROR:${NC}${wBG} Missing project name.${NC}"
|
| 104 |
+
exit 1
|
| 105 |
+
fi
|
| 106 |
+
|
| 107 |
+
if [ -d $JTROOT/cores/$PRJ ]; then
|
| 108 |
+
PRJPATH=$JTROOT/cores/$PRJ
|
| 109 |
+
else
|
| 110 |
+
echo -e "${rBG}ERROR:${NC}${wBG} Cannot find a valid project path${NC}"
|
| 111 |
+
exit 1
|
| 112 |
+
fi
|
| 113 |
+
shift
|
| 114 |
+
|
| 115 |
+
if [ -e $CORES/$PRJ/cfg/skip ]; then
|
| 116 |
+
echo "Skipping compilation of $PRJ because of cfg/skip file"
|
| 117 |
+
exit 0
|
| 118 |
+
fi
|
| 119 |
+
|
| 120 |
+
# Use the local release folder
|
| 121 |
+
export JTBIN=$JTROOT/release
|
| 122 |
+
mkdir -p $JTBIN
|
| 123 |
+
|
| 124 |
+
OUTPUTDIR=output_files
|
| 125 |
+
|
| 126 |
+
# Check Quartus path
|
| 127 |
+
case $TARGET in
|
| 128 |
+
mist) # MiST can only be compiled on Quartus 13, which is slower on systems with many CPU cores
|
| 129 |
+
if ! (which quartus_sh|grep 13 -q); then
|
| 130 |
+
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:.
|
| 131 |
+
if [ -d "/opt/altera/13.1" ]; then
|
| 132 |
+
PATH=$PATH:/opt/altera/13.1/quartus/bin
|
| 133 |
+
else
|
| 134 |
+
echo "Cannot find Quartus 13 in /opt/altera/13.1 (`hostname`)"
|
| 135 |
+
exit 1
|
| 136 |
+
fi
|
| 137 |
+
fi;;
|
| 138 |
+
*)
|
| 139 |
+
if ! (which quartus_sh|grep intelFPGA_lite -q); then
|
| 140 |
+
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:.
|
| 141 |
+
if [ -d /opt/intelFPGA_lite ]; then
|
| 142 |
+
cd /opt/intelFPGA_lite
|
| 143 |
+
cd $(ls | head -n 1)
|
| 144 |
+
PATH=$PATH:`pwd`/quartus/bin
|
| 145 |
+
else
|
| 146 |
+
echo "Cannot find Quartus in /opt/intelFPGA_lite (`hostname`)"
|
| 147 |
+
exit 1
|
| 148 |
+
fi
|
| 149 |
+
fi;;
|
| 150 |
+
esac
|
| 151 |
+
export PATH=$PATH:$JTFRAME/bin
|
| 152 |
+
|
| 153 |
+
make_macros_env_vars
|
| 154 |
+
# lower case version
|
| 155 |
+
corename=${CORENAME,,}
|
| 156 |
+
|
| 157 |
+
if [ -v JTFRAME_SKIP ]; then
|
| 158 |
+
echo "Compilation skipped for $TARGET because of JTFRAME_SKIP"
|
| 159 |
+
echo "Use -u JTFRAME_SKIP to override this."
|
| 160 |
+
echo "PASS"
|
| 161 |
+
exit 0
|
| 162 |
+
fi
|
| 163 |
+
|
| 164 |
+
START_TIME=$(date +%s)
|
| 165 |
+
echo =============== JTCORE =======================
|
| 166 |
+
echo -e "${wBG}$CORENAME $TARGET compilation ${blue}starts${NC}${wBG} at ${red}$(date +%T)${NC}${wBG} with seed ${red}$SEED${NC}${wBG} on $(hostname)${NC}"
|
| 167 |
+
if [ "$MACROS" != "" ]; then
|
| 168 |
+
echo -e Explicit macros:
|
| 169 |
+
for i in $MACROS; do
|
| 170 |
+
if [ ${i:0:17} != JTFRAME_UNLOCKKEY ]; then
|
| 171 |
+
echo -n "$i "
|
| 172 |
+
else # Do not print the key value
|
| 173 |
+
echo -n "JTFRAME_UNLOCKKEY "
|
| 174 |
+
fi
|
| 175 |
+
echo
|
| 176 |
+
done
|
| 177 |
+
fi
|
| 178 |
+
|
| 179 |
+
################ compilation
|
| 180 |
+
if [ $SKIP_COMPILE = FALSE ]; then
|
| 181 |
+
if ! which quartus_sh>/dev/null; then
|
| 182 |
+
echo -e "${rBG}ERROR:${NC}${wBG} cannot find quartus_sh in the path. Please add the correct path${NC}"
|
| 183 |
+
echo -e " ${wBG} to the PATH environment variable${NC}"
|
| 184 |
+
exit 1
|
| 185 |
+
fi
|
| 186 |
+
rm -rf $PRJPATH/$TARGET
|
| 187 |
+
mkdir -p $PRJPATH/$TARGET
|
| 188 |
+
cd $PRJPATH/$TARGET || exit 1
|
| 189 |
+
if [ -z "$NOLINTER" ]; then
|
| 190 |
+
lint_core $PRJ
|
| 191 |
+
fi
|
| 192 |
+
############################################
|
| 193 |
+
# Credits via jtframe_credits:
|
| 194 |
+
if [[ -e $PRJPATH/cfg/msg ]]; then
|
| 195 |
+
jtframe msg $PRJ || exit $?
|
| 196 |
+
fi
|
| 197 |
+
# Fonts and graphics
|
| 198 |
+
ln -srf $JTFRAME/bin/font0.hex
|
| 199 |
+
ln -srf $JTFRAME/hdl/video/logodata.hex
|
| 200 |
+
ln -srf $JTFRAME/hdl/video/logomap.hex
|
| 201 |
+
############################################
|
| 202 |
+
# Link filter files in case they are needed
|
| 203 |
+
for i in $JTFRAME/hdl/sound/*.hex; do
|
| 204 |
+
ln -srf $i $(basename $i) || exit $?
|
| 205 |
+
done
|
| 206 |
+
|
| 207 |
+
# If JT6295 exists, adds its filter file to the folder
|
| 208 |
+
if [ -d $MODULES/jt6295 ]; then
|
| 209 |
+
ln -srf $MODULES/jt6295/hdl/jt6295_up4.hex .
|
| 210 |
+
ln -srf $MODULES/jt6295/hdl/jt6295_up4_soft.hex .
|
| 211 |
+
fi
|
| 212 |
+
|
| 213 |
+
# Link .hex files in hdl, if they exist
|
| 214 |
+
for i in $PRJPATH/hdl/*.hex; do
|
| 215 |
+
if [ -e "$i" ]; then
|
| 216 |
+
ln -srf $i $PRJPATH/$TARGET/$(basename $i)
|
| 217 |
+
fi
|
| 218 |
+
done
|
| 219 |
+
|
| 220 |
+
############################################
|
| 221 |
+
# Recompile
|
| 222 |
+
rm -rf db incremental_db output_files
|
| 223 |
+
mkdir -p $JTROOT/log/$TARGET
|
| 224 |
+
LOG="$JTROOT/log/$TARGET/$corename.log"
|
| 225 |
+
echo Log file: $LOG
|
| 226 |
+
copy_templates
|
| 227 |
+
echo -e "\nset_global_assignment -name seed $SEED" >> $corename.qsf
|
| 228 |
+
if [ $SIM = FALSE ]; then
|
| 229 |
+
# Create the QIP file
|
| 230 |
+
if [ -e $CORES/$PRJ/cfg/mem.yaml ]; then jtframe mem $PRJ --target=$TARGET $NODBG || exit $?; fi
|
| 231 |
+
jtframe mmr $PRJ
|
| 232 |
+
jtframe files syn $PRJ --target=$TARGET || exit $?
|
| 233 |
+
# Compilation
|
| 234 |
+
quartus_sh -v
|
| 235 |
+
quartus_sh --flow compile $corename > "$LOG"
|
| 236 |
+
if ! grep "Full Compilation was successful" "$LOG"; then
|
| 237 |
+
grep -i error "$LOG" -A 2
|
| 238 |
+
echo -e "${rBG}ERROR:${NC}${wBG} while compiling the project. ${red}Aborting${NC}"
|
| 239 |
+
exit 1
|
| 240 |
+
fi
|
| 241 |
+
if [ ! -e $corename.map.rpt ]; then
|
| 242 |
+
RPTPATH=$OUTPUTDIR
|
| 243 |
+
else
|
| 244 |
+
RPTPATH=.
|
| 245 |
+
fi
|
| 246 |
+
(grep "SDRAM_.* is stuck" $RPTPATH/$corename.map.rpt | grep "SDRAM_[^\"]*" -o > $RPTPATH/sdram_stuck.rpt) || true
|
| 247 |
+
gawk -f $JTFRAME/bin/jtioreg.awk $RPTPATH/$corename.fit.rpt > $RPTPATH/sdram_io.rpt
|
| 248 |
+
cat $RPTPATH/sdram_stuck.rpt $RPTPATH/sdram_io.rpt | sort | uniq --unique > sdram_badio.rpt
|
| 249 |
+
if [ -s sdram_badio.rpt ]; then
|
| 250 |
+
echo -e "${yBG}WARNING:${NC}${wBG} some SDRAM signals are not IO registers${NC}"
|
| 251 |
+
cat sdram_badio.rpt
|
| 252 |
+
fi
|
| 253 |
+
if grep "inferring latch" $RPTPATH/jt$PRJ.map.rpt; then
|
| 254 |
+
echo "Warning: latch inferred"
|
| 255 |
+
fi
|
| 256 |
+
# Report FPGA usage
|
| 257 |
+
if [ $(find $RPTPATH -name "*.fit.summary"|wc -l) -gt 0 ]; then
|
| 258 |
+
grep "Total logic\|Logic utilization" $RPTPATH/*.fit.summary
|
| 259 |
+
grep "Total memory\|Total RAM" $RPTPATH/*.fit.summary
|
| 260 |
+
fi
|
| 261 |
+
# Report connectivity problems
|
| 262 |
+
AUX=`mktemp`
|
| 263 |
+
(grep \^Warning $LOG | grep \\.v | grep -v altera_pll\\.v \
|
| 264 |
+
| grep -v altera_cyclonev_pll\\.v \
|
| 265 |
+
| grep -v "\.data_a.*has no driver or initial value" \
|
| 266 |
+
| grep -v "\.waddr_a.*has no driver or initial value" \
|
| 267 |
+
| grep -v "\.we_a.*has no driver or initial value" \
|
| 268 |
+
| grep -v "Warning: RST port on the PLL" \
|
| 269 |
+
| grep -v "Warning: OUTCLK port on the PLL" \
|
| 270 |
+
| grep -v "Can't pack node.*to I/O pin" \
|
| 271 |
+
| grep -v "jitter performance" \
|
| 272 |
+
| grep -v "Warning \(10762\)" > $AUX) || true
|
| 273 |
+
if [[ "$MACROS" == *MISTER_DEBUG_NOHDMI* ]]; then
|
| 274 |
+
# There are many warnings coming from sys_top when HDMI is disabled, ignore them.
|
| 275 |
+
grep -v sys_top.v $AUX
|
| 276 |
+
else
|
| 277 |
+
cat $AUX
|
| 278 |
+
fi
|
| 279 |
+
rm -f $AUX
|
| 280 |
+
# Report timing
|
| 281 |
+
if grep --color=auto "Worst-case.*-[0-9.]*" "$LOG"; then
|
| 282 |
+
if [[ -z "$SKIPTIMING" && ! -v JTFRAME_NOSTA ]]; then
|
| 283 |
+
FAIL=1
|
| 284 |
+
fi
|
| 285 |
+
fi
|
| 286 |
+
if [ "$FAIL" = 0 ]; then
|
| 287 |
+
echo PASS
|
| 288 |
+
else
|
| 289 |
+
echo FAIL
|
| 290 |
+
fi
|
| 291 |
+
else
|
| 292 |
+
# Simulation
|
| 293 |
+
echo Preparing simulation netlist. Logfile:
|
| 294 |
+
echo $LOG
|
| 295 |
+
quartus_map $CORENAME --64bit --parallel=1 --efort=fast > "$LOG"
|
| 296 |
+
exit $?
|
| 297 |
+
fi
|
| 298 |
+
elif [ ! -z "$VERBOSE" ]; then
|
| 299 |
+
echo "Skipping compilation"
|
| 300 |
+
fi
|
| 301 |
+
|
| 302 |
+
################# Store output file
|
| 303 |
+
# Determine file extension
|
| 304 |
+
case $TARGET in
|
| 305 |
+
neptuno) EXT=np1;;
|
| 306 |
+
mc2) EXT=mc2;;
|
| 307 |
+
mcp) EXT=mcp;;
|
| 308 |
+
pocket) EXT=rbf_r;;
|
| 309 |
+
*) EXT=rbf;;
|
| 310 |
+
esac
|
| 311 |
+
|
| 312 |
+
# Rename output file
|
| 313 |
+
cd $JTROOT
|
| 314 |
+
|
| 315 |
+
if [ $SEED != 1 ]; then
|
| 316 |
+
SEED_SUFFIX=_$SEED
|
| 317 |
+
fi
|
| 318 |
+
|
| 319 |
+
# Do not use [[ ]] in this if statement !!
|
| 320 |
+
if is_mister_family || test $TARGET = neptuno; then
|
| 321 |
+
echo $TARGET
|
| 322 |
+
RBF=$PRJPATH/${TARGET}/$OUTPUTDIR/$corename.rbf
|
| 323 |
+
else
|
| 324 |
+
RBF=$PRJPATH/${TARGET}/$corename.rbf
|
| 325 |
+
fi
|
| 326 |
+
|
| 327 |
+
if [ ! -e $RBF ]; then
|
| 328 |
+
echo -e "${rBG}ERROR:${NC}${wBG} file ${red}$RBF${NC}${wBG} does not exist. You need to recompile.${NC}"
|
| 329 |
+
exit 1
|
| 330 |
+
fi
|
| 331 |
+
|
| 332 |
+
if [ $TARGET = pocket ]; then
|
| 333 |
+
# The Pocket must have something misconnected inside
|
| 334 |
+
# and it requires the bit order in each RBF byte to
|
| 335 |
+
# be reversed
|
| 336 |
+
if [ ! -e $JTFRAME/bin/reverse_bits ]; then
|
| 337 |
+
echo "Compiling reverse_bits"
|
| 338 |
+
cd $JTFRAME/cc
|
| 339 |
+
make
|
| 340 |
+
cd -
|
| 341 |
+
fi
|
| 342 |
+
$JTFRAME/bin/reverse_bits $RBF ${RBF}_r
|
| 343 |
+
RBF=${RBF}_r
|
| 344 |
+
fi
|
| 345 |
+
|
| 346 |
+
# Copy to JTBIN and SD card
|
| 347 |
+
if [[ "$FAIL" = 0 ]]; then
|
| 348 |
+
announce "Copy to $JTBIN"
|
| 349 |
+
BINFOLDER=$JTBIN/$TARGET
|
| 350 |
+
if [ $TARGET = pocket ]; then
|
| 351 |
+
BINFOLDER=$BINFOLDER/raw/Cores/jotego.$corename
|
| 352 |
+
fi
|
| 353 |
+
BINRBF=$BINFOLDER/$corename.$EXT
|
| 354 |
+
mkdir -p $(dirname $BINRBF)
|
| 355 |
+
cp -v $RBF $BINRBF || exit 1
|
| 356 |
+
if [ ! -z "$JTBIN2SD" ]; then jtbin2sd $JTBIN2SD; fi
|
| 357 |
+
elif [ ! -z "$VERBOSE" ]; then
|
| 358 |
+
echo "Skipping copy to release"
|
| 359 |
+
fi
|
| 360 |
+
rm -f $corename.rbf
|
| 361 |
+
|
| 362 |
+
###########################################
|
| 363 |
+
## Program the target device via JTAG
|
| 364 |
+
if [ $PROG = TRUE ]; then
|
| 365 |
+
announce "Device programming"
|
| 366 |
+
if [ $TARGET = mister ]; then
|
| 367 |
+
CABLE="DE-SoC"
|
| 368 |
+
cd $PRJPATH/mister
|
| 369 |
+
FILE=jtag.cdf
|
| 370 |
+
else
|
| 371 |
+
# if the cable is not recognized, run quartus_pgm -l
|
| 372 |
+
# and copy the cable name here
|
| 373 |
+
# this is not done automatically to speed up compilation
|
| 374 |
+
# as this rarely changes
|
| 375 |
+
CABLE=$(jtagconfig | grep -o "USB-Blaster.*")
|
| 376 |
+
FILE=$PRJPATH/${TARGET}/$corename.cdf
|
| 377 |
+
cat > $FILE << EOF
|
| 378 |
+
JedecChain;
|
| 379 |
+
FileRevision(JESD32A);
|
| 380 |
+
DefaultMfr(6E);
|
| 381 |
+
P ActionCode(Cfg)
|
| 382 |
+
Device PartName($DEVICE) Path("") File("$corename.sof") MfrSpec(OpMask(1));
|
| 383 |
+
ChainEnd;
|
| 384 |
+
|
| 385 |
+
AlteraBegin;
|
| 386 |
+
ChainType(JTAG);
|
| 387 |
+
AlteraEnd;
|
| 388 |
+
EOF
|
| 389 |
+
fi
|
| 390 |
+
PROGRETRY=2
|
| 391 |
+
while ! quartus_pgm -c "$CABLE" $FILE; do
|
| 392 |
+
PROGRETRY=$((PROGRETRY-1))
|
| 393 |
+
if [ $PROGRETRY -lt 0 ]; then
|
| 394 |
+
echo "Failed to program the device $DEVICE"
|
| 395 |
+
echo "See file $FILE for programming details"
|
| 396 |
+
break;
|
| 397 |
+
fi
|
| 398 |
+
done
|
| 399 |
+
fi
|
| 400 |
+
|
| 401 |
+
# Show compilation time
|
| 402 |
+
END_TIME=$(date +%s)
|
| 403 |
+
COMPILE_TIME=$[$END_TIME - $START_TIME]
|
| 404 |
+
MINUTES=$[$COMPILE_TIME / 60]
|
| 405 |
+
SECONDS=$[$COMPILE_TIME % 60]
|
| 406 |
+
|
| 407 |
+
echo -e "${gBG}completed${NC}${wBG} at $(date) - compile Time: ${red}${MINUTES}m${SECONDS}s${NC}"
|
| 408 |
+
exit $FAIL
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtcore-funcs
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
parse_args() {
|
| 2 |
+
while [ $# -gt 0 ]; do
|
| 3 |
+
case "$1" in
|
| 4 |
+
--corestamp)
|
| 5 |
+
if [ -z "$1" ]; then echo "Error: expecting word after --corestamp"; exit 1; fi
|
| 6 |
+
shift
|
| 7 |
+
CORESTAMP=$1;;
|
| 8 |
+
--credits)
|
| 9 |
+
MACROS="$MACROS NOSOUND MISTER_DEBUG_NOHDMI NOMAIN"
|
| 10 |
+
TARGET=mister;;
|
| 11 |
+
--def|-d)
|
| 12 |
+
shift
|
| 13 |
+
if [ ! -z "$1" ]; then
|
| 14 |
+
MACROS="$1 $MACROS"
|
| 15 |
+
fi
|
| 16 |
+
;;
|
| 17 |
+
--prog|-p) PROG=TRUE;;
|
| 18 |
+
--prog-only | -w)
|
| 19 |
+
PROG=TRUE
|
| 20 |
+
SKIP_COMPILE=TRUE;;
|
| 21 |
+
--quick|-q)
|
| 22 |
+
MACROS="$MACROS NOSOUND JTFRAME_OSD_NOLOGO JTFRAME_NOHQ2X"
|
| 23 |
+
UNMACROS="$UNMACROS JTFRAME_CREDITS";;
|
| 24 |
+
-qs)
|
| 25 |
+
MACROS="$MACROS JTFRAME_OSD_NOLOGO JTFRAME_NOHQ2X"
|
| 26 |
+
UNMACROS="$UNMACROS JTFRAME_CREDITS";;
|
| 27 |
+
--skip | -s) SKIP_COMPILE=TRUE;;
|
| 28 |
+
--quicker|-qq)
|
| 29 |
+
MACROS="$MACROS NOSOUND JTFRAME_OSD_NOLOGO JTFRAME_NOHQ2X MISTER_DEBUG_NOHDMI MISTER_DISABLE_YC"
|
| 30 |
+
UNMACROS="$UNMACROS JTFRAME_CREDITS"
|
| 31 |
+
TARGET=mister;;
|
| 32 |
+
-mr)
|
| 33 |
+
TARGET=mister;;
|
| 34 |
+
--mrpasswd)
|
| 35 |
+
shift
|
| 36 |
+
if [ -z "$1" ]; then echo "Error: expecting word after --mrpasswd"; exit 1; fi
|
| 37 |
+
MISTERPASSWD=$1;;
|
| 38 |
+
-mrq)
|
| 39 |
+
MACROS="$MACROS JTFRAME_OSD_NOLOGO JTFRAME_NOHQ2X MISTER_DEBUG_NOHDMI MISTER_DISABLE_YC"
|
| 40 |
+
UNMACROS="$UNMACROS JTFRAME_CREDITS"
|
| 41 |
+
TARGET=mister;;
|
| 42 |
+
--nodbg) NODBG=--nodbg; MACROS="$MACROS JTFRAME_RELEASE=1";;
|
| 43 |
+
--nolinter) NOLINTER=1;;
|
| 44 |
+
--nosta) SKIPTIMING=1;;
|
| 45 |
+
--sim) SIM=TRUE;;
|
| 46 |
+
--sd)
|
| 47 |
+
if [ "${2:0:1}" != - ]; then
|
| 48 |
+
shift
|
| 49 |
+
JTBIN2SD=$1
|
| 50 |
+
else
|
| 51 |
+
JTBIN2SD=" "
|
| 52 |
+
fi;;
|
| 53 |
+
--showmacros) SHOWMACROS=1;;
|
| 54 |
+
--target|-t)
|
| 55 |
+
shift
|
| 56 |
+
if [[ ! -d "$JTFRAME/target/$1" || -z "$1" ]]; then
|
| 57 |
+
echo "Target $1 does not exist in $JTFRAME/target"
|
| 58 |
+
exit 1
|
| 59 |
+
fi
|
| 60 |
+
TARGET=$1;;
|
| 61 |
+
--seed)
|
| 62 |
+
shift
|
| 63 |
+
if [[ ! $1 =~ ^[0-9]+$ ]]; then
|
| 64 |
+
echo "Error: use an integer after --seed"
|
| 65 |
+
exit 1
|
| 66 |
+
fi
|
| 67 |
+
SEED=$1;;
|
| 68 |
+
--undef|-u)
|
| 69 |
+
shift
|
| 70 |
+
if [ -z "$1" ]; then echo "Error: expecting word after --undef"; exit 1; fi
|
| 71 |
+
UNMACROS="$1 $UNMACROS"
|
| 72 |
+
;;
|
| 73 |
+
--verbose | -v)
|
| 74 |
+
VERBOSE=-v;;
|
| 75 |
+
--version)
|
| 76 |
+
cd $JTROOT; latest.sh
|
| 77 |
+
exit 0;;
|
| 78 |
+
--help | -h)
|
| 79 |
+
show_usage;;
|
| 80 |
+
*) if [[ -z "$PRJ" && ${1:0:1} != - ]]; then
|
| 81 |
+
PRJ=$1
|
| 82 |
+
elif [ -d "$JTFRAME/target/${1:1}" ]; then
|
| 83 |
+
# the name is a valid target because there was a folder for it in $JTFRAME/target
|
| 84 |
+
TARGET=${1:1}
|
| 85 |
+
else
|
| 86 |
+
echo "Project name had already been defined to " $PRJ
|
| 87 |
+
echo -e "${rBG}ERROR:${NC}${wBG} Unknown option ${red}$1${NC}";
|
| 88 |
+
exit 1
|
| 89 |
+
fi
|
| 90 |
+
;;
|
| 91 |
+
esac
|
| 92 |
+
shift
|
| 93 |
+
done
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
show_usage() {
|
| 97 |
+
cat << EOF
|
| 98 |
+
JTCORE compilation tool. (c) Jose Tejada 2019-2023, @topapate
|
| 99 |
+
usage: jtcore <corename> [options]
|
| 100 |
+
|
| 101 |
+
jtcore compiles only one core at a time. To compile many cores at once
|
| 102 |
+
use jtupdate.
|
| 103 |
+
|
| 104 |
+
Macro definition
|
| 105 |
+
--def | -d Defines a verilog macro. Macros are removed from qsf file after
|
| 106 |
+
compilation.
|
| 107 |
+
Useful macros:
|
| 108 |
+
NOSOUND the core is compiled without sound (faster)
|
| 109 |
+
MISTER_VIDEO_MIXER uses the Mr video modules
|
| 110 |
+
JTFRAME_SCAN2X uses simple scan doubler from JTFRAME
|
| 111 |
+
MISTER_DEBUG_NOHDMI skips MiSTer HDMI related logic. Speeds up compilation.
|
| 112 |
+
--undef | -u Undefines a macro
|
| 113 |
+
|
| 114 |
+
Target selection
|
| 115 |
+
-mist compiles the MiST version. This is the default
|
| 116 |
+
-mister compiles the MiSTer version
|
| 117 |
+
-sidi compiles the SIDI version. This uses MiST's folders and settings but different pinout
|
| 118 |
+
-neptuno compiles the NeptUNO version
|
| 119 |
+
-mc2 compiles the MultiCore2 version
|
| 120 |
+
-mcp compiles the MultiCore2+ version
|
| 121 |
+
-pocket compiles the PocketFPGA version
|
| 122 |
+
-sockit compiles the Arrow SoCKit version
|
| 123 |
+
-de1soc compiles the Terasic DE1-SoC version
|
| 124 |
+
-de10std compiles the Terasic DE10-Standard version
|
| 125 |
+
-folder any folder present in $JTFRAME/target/folder can be used as the target
|
| 126 |
+
|
| 127 |
+
General options
|
| 128 |
+
|
| 129 |
+
--corestamp Sets the date string attached to the RBF file name. Defaults to today
|
| 130 |
+
--credits Defines NOSOUND, MISTER_DEBUG_NOHDMI and NOMAIN. Sets MiSTer as target.
|
| 131 |
+
-mrq Compiles MiSTer with no HDMI nor logo but with sound
|
| 132 |
+
--mrpasswd Sets the SSH pasword to use on MiSTer
|
| 133 |
+
--nodbg Defines JTFRAME_RELEASE
|
| 134 |
+
--nosta skips the STA check and marks as PASS compilations with timing problems
|
| 135 |
+
--nolinter Do not run the verilator linter
|
| 136 |
+
--program | -p Programs the FPGA via JTAG
|
| 137 |
+
--quick |-q Quick compilation. Defines NOSOUND and JTFRAME_OSD_NOLOGO
|
| 138 |
+
Disables JTFRAME_CREDITS and HQ2X.
|
| 139 |
+
-qs Same as -q but with sound.
|
| 140 |
+
--quicker | -qq Same as -q but it also disabled HDMI output and sets MiSTer as target
|
| 141 |
+
--sd [setname] Copy to sd card, optional setname (uses jtbin2sd)
|
| 142 |
+
--seed Sets random seed for compilation
|
| 143 |
+
--sim Prepares Quartus simulation
|
| 144 |
+
--skip | -s skips the compilation but executes the rest of the commands
|
| 145 |
+
--showmacros Shows the macros used for compilation and exits
|
| 146 |
+
--target | -t <target>
|
| 147 |
+
Specifies the target platform
|
| 148 |
+
--verbose | -v verbose
|
| 149 |
+
--version Shows the core version. Use "jtmerge -v" to see the JTFRAME version
|
| 150 |
+
|
| 151 |
+
--help Displays this message
|
| 152 |
+
EOF
|
| 153 |
+
exit 0
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
lint_core() {
|
| 158 |
+
local core="$1"
|
| 159 |
+
local log=`mktemp`
|
| 160 |
+
local fail
|
| 161 |
+
if ! $JTFRAME/bin/lint-one.sh $core > /dev/null 2> $log; then
|
| 162 |
+
cat $log
|
| 163 |
+
fail=1
|
| 164 |
+
fi
|
| 165 |
+
if grep ^%Warning $log; then
|
| 166 |
+
cat $log
|
| 167 |
+
fail=1
|
| 168 |
+
fi
|
| 169 |
+
rm -f $log
|
| 170 |
+
if [ "$fail" = 1 ]; then
|
| 171 |
+
exit 1
|
| 172 |
+
fi
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
# Sets the commit string to a short commit and an optional -dirty suffix
|
| 176 |
+
is_dirty() {
|
| 177 |
+
git status --short | grep -i "^ M " > /dev/null
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
escape_bars() {
|
| 181 |
+
echo ${1//\//\\/}
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
macros2def() {
|
| 185 |
+
local MM=""
|
| 186 |
+
for i in $MACROS; do
|
| 187 |
+
MM="$i,$MM"
|
| 188 |
+
done
|
| 189 |
+
if [ ! -z "$MM" ]; then
|
| 190 |
+
MM="--def $MM"
|
| 191 |
+
fi
|
| 192 |
+
echo $MM
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
umacros2undef() {
|
| 196 |
+
local UM=""
|
| 197 |
+
for i in $UNMACROS; do
|
| 198 |
+
UM="$i,$UM"
|
| 199 |
+
done
|
| 200 |
+
if [ ! -z "$UM" ]; then
|
| 201 |
+
UM="--undef $UM"
|
| 202 |
+
fi
|
| 203 |
+
echo $UM
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
make_macros_env_vars() {
|
| 207 |
+
local macros
|
| 208 |
+
macros=`parse_macros bash`
|
| 209 |
+
if [ $? != 0 ]; then echo "Stopping at macro conversion"; exit 1; fi
|
| 210 |
+
eval "$macros"
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
parse_macros() {
|
| 214 |
+
if [ ! -z "$VERBOSE" ]; then
|
| 215 |
+
echo jtframe cfgstr $PRJ $NODBG --target=$TARGET `macros2def` `umacros2undef` --output $* > /dev/stderr
|
| 216 |
+
fi
|
| 217 |
+
jtframe cfgstr $PRJ $NODBG --target=$TARGET `macros2def` `umacros2undef` --output $*
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
# qsf line to disable SOUND synthesis
|
| 221 |
+
# set_global_assignment -name VERILOG_MACRO "NOSOUND=<None>"
|
| 222 |
+
copy_templates() {
|
| 223 |
+
jtframe parse $PRJ $JTFRAME/target/$TARGET/$TARGET.qpf `macros2def` --output $PRJPATH/$TARGET/$corename.qpf || exit $?
|
| 224 |
+
jtframe parse $PRJ $JTFRAME/target/$TARGET/$TARGET.qsf `macros2def` --output $PRJPATH/$TARGET/$corename.qsf || exit $?
|
| 225 |
+
MACROS_FILE=$PRJPATH/cfg/macros.def
|
| 226 |
+
QSF=$PRJPATH/$TARGET/$corename.qsf
|
| 227 |
+
# Add definitions in "macros" files
|
| 228 |
+
if [ -e $MACROS_FILE ]; then
|
| 229 |
+
echo >> $QSF # add blank line
|
| 230 |
+
(parse_macros quartus | sort >> $QSF) || exit $?
|
| 231 |
+
if [ -n "$SHOWMACROS" ]; then
|
| 232 |
+
gawk -f $JTFRAME/bin/jtmacros.awk target=$TARGET $MACROS_FILE
|
| 233 |
+
exit 0
|
| 234 |
+
fi
|
| 235 |
+
# Prepare config string
|
| 236 |
+
parse_macros cfgstr > $JTROOT/log/$TARGET/cfgstr || exit $?
|
| 237 |
+
fi
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
append_if_exists() {
|
| 241 |
+
val=
|
| 242 |
+
while [ $# -gt 0 ]; do
|
| 243 |
+
if [ -e "$1" ]; then
|
| 244 |
+
val="$val $1"
|
| 245 |
+
fi
|
| 246 |
+
shift
|
| 247 |
+
done
|
| 248 |
+
echo $val
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
announce() {
|
| 252 |
+
if [ ! -z "$VERBOSE" ]; then echo "== $* =="; fi
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
is_mister_family() {
|
| 256 |
+
if [[ $TARGET = mister || $TARGET = sockit || $TARGET = de1soc || $TARGET = de10std ]]; then
|
| 257 |
+
return 0
|
| 258 |
+
else
|
| 259 |
+
return 1
|
| 260 |
+
fi
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
# derive the default core name from the path
|
| 264 |
+
get_corename_from_folder() {
|
| 265 |
+
local defprj
|
| 266 |
+
defprj=$(realpath . --relative-to=$CORES)
|
| 267 |
+
if [[ "$defprj" == ..* ]]; then
|
| 268 |
+
echo "Execute the program from a folder in $CORES" >&2
|
| 269 |
+
exit 1
|
| 270 |
+
fi
|
| 271 |
+
echo ${defprj%%/*}
|
| 272 |
+
}
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtcore13
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
if [ -z "$1" ]; then
|
| 3 |
+
echo "Use jtcore13 <core-name> to compile a core for MiST using jtseed"
|
| 4 |
+
exit 0
|
| 5 |
+
fi
|
| 6 |
+
corename="$1"
|
| 7 |
+
cd $JTROOT
|
| 8 |
+
runscript=`mktemp`
|
| 9 |
+
cat <<EOF > $runscript
|
| 10 |
+
export PATH=$PATH:/usr/local/go/bin:/opt/altera/13.1/quartus/bin
|
| 11 |
+
git config --global --add safe.directory /jtcores
|
| 12 |
+
git config --global --add safe.directory /jtcores/modules/jtframe/target/pocket
|
| 13 |
+
cd jtcores
|
| 14 |
+
./setprj.sh
|
| 15 |
+
jtframe
|
| 16 |
+
./setprj.sh jtseed 3 $corename --target mist --nodbg --nolinter
|
| 17 |
+
EOF
|
| 18 |
+
docker run -i --rm -v $PWD:/jtcores jotego/jtcore13 < $runscript
|
| 19 |
+
rm $runscript
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtcrtcfg.py
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Script for choosing settings on Analogizer
|
| 2 |
+
# Author: Rafael Eduardo Paiva Feener. Copyright: Miki Saito
|
| 3 |
+
# Version: 1.0
|
| 4 |
+
# Date: 10-6-2024
|
| 5 |
+
|
| 6 |
+
import binascii
|
| 7 |
+
import argparse
|
| 8 |
+
import glob
|
| 9 |
+
import os
|
| 10 |
+
|
| 11 |
+
def find_sd_card_path(sd_card_name):
|
| 12 |
+
sd_path = glob.glob(f'/media/*/{sd_card_name}')
|
| 13 |
+
if sd_path:
|
| 14 |
+
return sd_path[0]
|
| 15 |
+
else:
|
| 16 |
+
return None
|
| 17 |
+
|
| 18 |
+
def create_in_pocket(do=False, filename="crtcfg.bin", find="POCKET", common="/Assets/jtpatreon/common/"):
|
| 19 |
+
if do:
|
| 20 |
+
pocketpath = find_sd_card_path(find)
|
| 21 |
+
if pocketpath == None:
|
| 22 |
+
print("No SD card detected. File will be created in current path")
|
| 23 |
+
return filename
|
| 24 |
+
if not os.path.exists(pocketpath+common): os.makedirs(pocketpath+common)
|
| 25 |
+
finalpath = pocketpath+common+filename
|
| 26 |
+
return finalpath
|
| 27 |
+
return filename
|
| 28 |
+
|
| 29 |
+
def create_in_release(do=False, filename="crtcfg.bin", find="jtcores/release", common="/pocket/raw/Assets/jtpatreon/common/"):
|
| 30 |
+
if do:
|
| 31 |
+
search = os.path.join(os.path.expanduser("~"),f'**/{find}')
|
| 32 |
+
rel = glob.glob(search, recursive=True)
|
| 33 |
+
if rel:
|
| 34 |
+
releasepath = rel[0]
|
| 35 |
+
else:
|
| 36 |
+
releasepath = None
|
| 37 |
+
print("Release folder could not be found")
|
| 38 |
+
return filename
|
| 39 |
+
if not os.path.exists(releasepath+common): os.makedirs(releasepath+common)
|
| 40 |
+
finalpath = releasepath+common+filename
|
| 41 |
+
return finalpath
|
| 42 |
+
return filename
|
| 43 |
+
|
| 44 |
+
class OptionType:
|
| 45 |
+
def __init__(self, exp1=True, skp=["u"]):
|
| 46 |
+
self.options = ""
|
| 47 |
+
self.dict = {}
|
| 48 |
+
self.replace = {}
|
| 49 |
+
self.expect1 = exp1
|
| 50 |
+
self.skip = ''.join(skp)
|
| 51 |
+
def get_input(self):
|
| 52 |
+
inp = input(self.options).lower()
|
| 53 |
+
nf = ""
|
| 54 |
+
if self.expect1 and len(inp)>1:
|
| 55 |
+
print(f"\nExpected input lenght: 1\nInput lenght found: {len(inp)}\nTry again.")
|
| 56 |
+
return self.get_input()
|
| 57 |
+
if self.replace:
|
| 58 |
+
for r in self.replace: inp = inp.replace( r,self.replace[r] )
|
| 59 |
+
for let in set(inp):
|
| 60 |
+
if let not in self.dict or let in self.skip: nf += let
|
| 61 |
+
else: self.dict[let][0] += 1
|
| 62 |
+
if nf: print(f"Sorry, could not find following options: '{nf.upper()}'. Inputs ignored\n")
|
| 63 |
+
return inp
|
| 64 |
+
|
| 65 |
+
def user_options(records, w_len=32, filename="test.bin",filename2=None):
|
| 66 |
+
final_num = ""
|
| 67 |
+
files = [filename, filename2]
|
| 68 |
+
if filename==filename2: files[1] = None
|
| 69 |
+
for sel in records:
|
| 70 |
+
sel_input = sel.get_input() # input(sel.options).lower()
|
| 71 |
+
#Add options to Binary string
|
| 72 |
+
for it in sel.dict:
|
| 73 |
+
for s in sel.dict[it]:
|
| 74 |
+
final_num += str(s)
|
| 75 |
+
#Rellenar valores faltantes con 0 a la derecha
|
| 76 |
+
if len(final_num) < w_len: final_num += "0"*(w_len-len(final_num))
|
| 77 |
+
hex_str = hex(int(final_num,2))[2:].zfill(w_len // 4)
|
| 78 |
+
|
| 79 |
+
#print(hex_str,len(final_num), final_num)
|
| 80 |
+
# Guardar los datos binarios en un archivo
|
| 81 |
+
for f in files:
|
| 82 |
+
if f==None: continue
|
| 83 |
+
with open(f, 'wb') as binary_file:
|
| 84 |
+
binary_file.write(binascii.unhexlify(hex_str))
|
| 85 |
+
|
| 86 |
+
parser = argparse.ArgumentParser()
|
| 87 |
+
parser.add_argument('--sd', action='store_true')
|
| 88 |
+
parser.add_argument('--release', action='store_true')
|
| 89 |
+
args = parser.parse_args()
|
| 90 |
+
sd = False
|
| 91 |
+
if args.sd==True: sd = args.sd
|
| 92 |
+
rel = False
|
| 93 |
+
if args.release==True: rel = args.release
|
| 94 |
+
# Crear el objeto 'crt' de la clase 'OptionType'
|
| 95 |
+
crt = OptionType()
|
| 96 |
+
|
| 97 |
+
crt.options ="""
|
| 98 |
+
Please, select your prefered Video Option.
|
| 99 |
+
For example: A for RGB video
|
| 100 |
+
|
| 101 |
+
Letter | Option
|
| 102 |
+
-------|--------------------------------------------|
|
| 103 |
+
A | RBGS (SCART) |
|
| 104 |
+
B | RGsB |
|
| 105 |
+
C | YPbPr (Component video) |
|
| 106 |
+
D | Y/C NTSC (SVideo, Composite video) |
|
| 107 |
+
E | Y/C PAL (SVideo, Composite video) |
|
| 108 |
+
F | Scandoubler RGBHV (SCANLINES 0%) |
|
| 109 |
+
G | Scandoubler RGBHV (SCANLINES 25%) |
|
| 110 |
+
H | Scandoubler RGBHV (SCANLINES 50%) |
|
| 111 |
+
I | Scandoubler RGBHV (SCANLINES 75%) |
|
| 112 |
+
X | Disable Analog Video |
|
| 113 |
+
----------------------------------------------------|
|
| 114 |
+
|
| 115 |
+
Your selection: """
|
| 116 |
+
|
| 117 |
+
crt.dict = {
|
| 118 |
+
"a" : [0], "b" : [0],
|
| 119 |
+
"c" : [0], "k" : [0],
|
| 120 |
+
"l" : [0], "u" : [0],
|
| 121 |
+
"d" : [0], "i" : [0],
|
| 122 |
+
"j" : [0], "h" : [0],
|
| 123 |
+
"g" : [0], "f" : [0],
|
| 124 |
+
}
|
| 125 |
+
crt.replace = {"f": "af", "h": "afh",
|
| 126 |
+
"g": "afg", "i": "afgh",
|
| 127 |
+
"e": "akl", "d": "ak" ,
|
| 128 |
+
"c": "acj", "b": "abj",
|
| 129 |
+
"x": "", "a": "ad"}
|
| 130 |
+
|
| 131 |
+
snac = OptionType()
|
| 132 |
+
|
| 133 |
+
snac.options = """
|
| 134 |
+
Please, select the option corresponding to your controller.
|
| 135 |
+
|
| 136 |
+
Letter | Option
|
| 137 |
+
-------|--------------------------------------------|
|
| 138 |
+
A | None |
|
| 139 |
+
B | DB15 Normal |
|
| 140 |
+
C | NES |
|
| 141 |
+
D | SNES |
|
| 142 |
+
E | PCE 2BTN/6BTN |
|
| 143 |
+
F | PCE Multitap |
|
| 144 |
+
----------------------------------------------------|
|
| 145 |
+
|
| 146 |
+
Your selection: """
|
| 147 |
+
|
| 148 |
+
snac.dict = {
|
| 149 |
+
"u" : [0,0,0],
|
| 150 |
+
"a" : [0],
|
| 151 |
+
"f" : [0],
|
| 152 |
+
"e" : [0],
|
| 153 |
+
"c" : [0],
|
| 154 |
+
"b" : [0],
|
| 155 |
+
}
|
| 156 |
+
snac.replace = {"a": "", "e":"eb", "f":"ec","d":"cb"}
|
| 157 |
+
|
| 158 |
+
filepath = create_in_pocket(do=sd)
|
| 159 |
+
filepath2 = create_in_release(do=rel)
|
| 160 |
+
user_options([crt, snac],filename=filepath, filename2=filepath2)
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtframe
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -e
|
| 2 |
+
POCKET=
|
| 3 |
+
|
| 4 |
+
if [ -z "$JTFRAME" ]; then
|
| 5 |
+
echo "Missing JTFRAME environment variable definition"
|
| 6 |
+
exit 1
|
| 7 |
+
fi
|
| 8 |
+
|
| 9 |
+
RECOMPILE=FALSE
|
| 10 |
+
BIN=$JTFRAME/src/jtframe/jtframe
|
| 11 |
+
|
| 12 |
+
if [[ ! -e $BIN || $# = 0 ]]; then # recompile if file missing or no arguments
|
| 13 |
+
RECOMPILE=TRUE
|
| 14 |
+
else
|
| 15 |
+
# Find out whether the jtframe file is older
|
| 16 |
+
# than the JTFRAME's commit
|
| 17 |
+
cd $JTFRAME > /dev/null
|
| 18 |
+
COMMIT_DATE=`date -d "$(git show -s --format=%ci)" +"%s"`
|
| 19 |
+
COMPILED_DATE=`stat -c %Y $BIN`
|
| 20 |
+
if [ $COMPILED_DATE -lt $COMMIT_DATE ]; then
|
| 21 |
+
RECOMPILE=TRUE
|
| 22 |
+
fi
|
| 23 |
+
cd - > /dev/null
|
| 24 |
+
fi
|
| 25 |
+
|
| 26 |
+
function run_tests {
|
| 27 |
+
LOG=`mktemp`
|
| 28 |
+
if ! go test ./... > $LOG; then
|
| 29 |
+
cat $LOG
|
| 30 |
+
rm -f $LOG
|
| 31 |
+
exit 1
|
| 32 |
+
fi
|
| 33 |
+
rm -f $LOG
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
if [ $RECOMPILE = TRUE ]; then
|
| 37 |
+
if [ -e $JTFRAME/target/pocket/pocket.go ]; then
|
| 38 |
+
ln -sf $JTFRAME/target/pocket/pocket.go $JTFRAME/src/jtframe/mra/pocket.go
|
| 39 |
+
POCKET="-tags pocket"
|
| 40 |
+
echo "Compiling jtframe with Pocket support" > /dev/stderr
|
| 41 |
+
fi
|
| 42 |
+
cd $JTFRAME/src/jtframe > /dev/null
|
| 43 |
+
run_tests
|
| 44 |
+
go build $POCKET . || exit $?
|
| 45 |
+
cd - > /dev/null
|
| 46 |
+
fi
|
| 47 |
+
|
| 48 |
+
$BIN $*
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtgood
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
CORE=$1
|
| 3 |
+
shift
|
| 4 |
+
if [ -z "$CORE" ]; then
|
| 5 |
+
cat <<EOF
|
| 6 |
+
Use jtgood <corename>
|
| 7 |
+
|
| 8 |
+
jtgood is useful when combined with git bisect command
|
| 9 |
+
In order to find the commit that broke a core do:
|
| 10 |
+
|
| 11 |
+
git bisect start
|
| 12 |
+
git bisect bad
|
| 13 |
+
git bisect good good_rev_id
|
| 14 |
+
git bisect run jtgood <corename> [-q]
|
| 15 |
+
EOF
|
| 16 |
+
exit 1
|
| 17 |
+
fi
|
| 18 |
+
cd modules/jtframe/target
|
| 19 |
+
git submodule update pocket
|
| 20 |
+
rm -f ../src/jtframe/jtframe
|
| 21 |
+
jtframe
|
| 22 |
+
jtframe mra $CORE; jtcore $CORE $*; jtbin2sd
|
| 23 |
+
echo "Good y/n?"
|
| 24 |
+
read RSLT
|
| 25 |
+
if [ "$RSLT" = y ]; then
|
| 26 |
+
exit 0
|
| 27 |
+
fi
|
| 28 |
+
exit 1
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtioreg.awk
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/awk -f
|
| 2 |
+
# Provides a list of SDRAM pins that have not been assigned to I/O registers
|
| 3 |
+
BEGIN {
|
| 4 |
+
FS=";"
|
| 5 |
+
dump=0
|
| 6 |
+
}
|
| 7 |
+
/^; Output Pins/ {
|
| 8 |
+
dump=1
|
| 9 |
+
next
|
| 10 |
+
}
|
| 11 |
+
/^; Bidir Pins/ {
|
| 12 |
+
dump=2
|
| 13 |
+
next
|
| 14 |
+
}
|
| 15 |
+
/^;/ {
|
| 16 |
+
if( dump==1 ) {
|
| 17 |
+
# $2 = pin name
|
| 18 |
+
# $8 = output register
|
| 19 |
+
if( match($2,"SDRAM_") && match($8,"no") && match($2,"SDRAM_CLK")==0) {
|
| 20 |
+
gsub(/ /,"",$2)
|
| 21 |
+
print $2
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
if( dump==2 ) {
|
| 25 |
+
# $2 = pin name
|
| 26 |
+
# $11 = input register
|
| 27 |
+
# $12 = output register
|
| 28 |
+
# print $2,$11,$12
|
| 29 |
+
if( match($2,"SDRAM_") && (match($11,"no") || match($12,"no")) )
|
| 30 |
+
if( match($2,"SDRAM_CLK")==0 ) {
|
| 31 |
+
#gsub(/ /,"",$2)
|
| 32 |
+
print $2
|
| 33 |
+
}
|
| 34 |
+
}
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
/^$/{
|
| 38 |
+
# print "Dump to zero"
|
| 39 |
+
dump=0
|
| 40 |
+
}
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtnet.sh
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
source setprj.sh > /dev/null
|
| 3 |
+
export JTBIN=$1
|
| 4 |
+
shift
|
| 5 |
+
$*
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtreg
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
START_TIME=$(date +%s)
|
| 3 |
+
CORE=$1
|
| 4 |
+
shift
|
| 5 |
+
|
| 6 |
+
if [ -z "$CORE" ]; then echo "Missing core name"; exit 1; fi
|
| 7 |
+
if [ ! -d "$CORES/$CORE" ]; then echo "No core named $CORE in $CORES"; exit 1; fi
|
| 8 |
+
|
| 9 |
+
jtframe mra --mainonly $CORE
|
| 10 |
+
SETNAMES=`cat $CORES/$CORE/ver/setnames.txt`
|
| 11 |
+
|
| 12 |
+
if [ -z "$SETNAMES" ]; then
|
| 13 |
+
echo "No MAME set supported for $CORENAME ($CORE)"
|
| 14 |
+
exit 0
|
| 15 |
+
fi
|
| 16 |
+
|
| 17 |
+
REGDIR=$CORES/$CORE/ver/regrun
|
| 18 |
+
mkdir -p $REGDIR || exit $?
|
| 19 |
+
cd $REGDIR || exit $?
|
| 20 |
+
find -not -name "." -type d | xargs rm -rf
|
| 21 |
+
|
| 22 |
+
export JTFRAME_REGRESSION=1
|
| 23 |
+
parallel --jobs 75% --delay 0.5 jtsim -sysname $CORE -video 900 -dir -skipROM $* -setname ::: $SETNAMES
|
| 24 |
+
END_TIME=$(date +%s)
|
| 25 |
+
COMPILE_TIME=$[$END_TIME - $START_TIME]
|
| 26 |
+
HOURS=$[$COMPILE_TIME / 3600]
|
| 27 |
+
MINUTES=$[$COMPILE_TIME / 60]
|
| 28 |
+
SECONDS=$[$COMPILE_TIME % 60]
|
| 29 |
+
|
| 30 |
+
echo "====== $CORE regression finished in "$HOURS:$MINUTES:$SECONDS hours" ======" > /dev/stderr
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtreg-list.sh
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
find $CORES -name setnames.txt -delete
|
| 3 |
+
for i in `find $CORES -maxdepth 1 -type d | xargs -l1 realpath --relative-to=$CORES`; do
|
| 4 |
+
if [ -e $CORES/$i/cfg/macros.def ]; then
|
| 5 |
+
jtframe mra --skipROM --mainonly --skipPocket $i
|
| 6 |
+
else
|
| 7 |
+
echo "Skipping $i"
|
| 8 |
+
fi
|
| 9 |
+
done
|
| 10 |
+
|
| 11 |
+
cd $CORES
|
| 12 |
+
LOG=$JTROOT/log/reglist.log
|
| 13 |
+
rm -f $LOG
|
| 14 |
+
for i in `find -name setnames.txt`; do
|
| 15 |
+
CORE=`echo $i | cut -d"/" -f2`
|
| 16 |
+
while IFS= read -r line; do
|
| 17 |
+
echo $(basename $CORE) "$line" >> $LOG
|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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
clean_up() {
|
| 4 |
+
if [[ ! -z "$DST" && -d "$DST" ]]; then
|
| 5 |
+
echo "Deleting $DST"
|
| 6 |
+
rm -rf "$DST";
|
| 7 |
+
fi
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
parse_args() {
|
| 11 |
+
HASH=
|
| 12 |
+
LAST=
|
| 13 |
+
SKIPROM=--skipROM
|
| 14 |
+
VERBOSE=
|
| 15 |
+
while [ $# -gt 0 ]; do
|
| 16 |
+
case "$1" in
|
| 17 |
+
-l|--local)
|
| 18 |
+
unset JTBIN;;
|
| 19 |
+
--last)
|
| 20 |
+
LAST="--last";;
|
| 21 |
+
--host)
|
| 22 |
+
shift
|
| 23 |
+
export MRHOST=$1;;
|
| 24 |
+
-r|--rom)
|
| 25 |
+
SKIPROM=;;
|
| 26 |
+
-v|--verbose)
|
| 27 |
+
VERBOSE=1;;
|
| 28 |
+
-h|--help)
|
| 29 |
+
show_help
|
| 30 |
+
exit 0;;
|
| 31 |
+
*) if [[ -z "$HASH" && ${1:0:1} != - ]]; then
|
| 32 |
+
HASH=`git rev-parse --short $1`
|
| 33 |
+
HASH=${HASH:0:7}
|
| 34 |
+
else
|
| 35 |
+
echo "Do not know what to do with arguments $HASH and $1"
|
| 36 |
+
exit 1
|
| 37 |
+
fi
|
| 38 |
+
esac
|
| 39 |
+
shift
|
| 40 |
+
done
|
| 41 |
+
if [ -z "$HASH" ]; then
|
| 42 |
+
echo "Missing hash argument"
|
| 43 |
+
exit 1
|
| 44 |
+
fi
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
show_help() {
|
| 48 |
+
cat<<EOF
|
| 49 |
+
jtrelease.sh <hash> [arguments]
|
| 50 |
+
|
| 51 |
+
Copies a build to the SD card,MiSTer and JTBIN $JTBIN
|
| 52 |
+
Either the full path to the file is provided, or just the
|
| 53 |
+
hash to it, and the file is looked upon in the \$JTBUILDS path $JTBUILDS
|
| 54 |
+
|
| 55 |
+
-h, --help This help screen
|
| 56 |
+
-l, --local Do not copy to JTBIN
|
| 57 |
+
--last Use last friday's date, instead of next's
|
| 58 |
+
or latest published date, if it is more recent
|
| 59 |
+
than last friday's
|
| 60 |
+
--host MiSTer host name
|
| 61 |
+
-r, --rom Regenerate ROM files
|
| 62 |
+
-v, --verbose Verbose
|
| 63 |
+
EOF
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
check_jtbin() {
|
| 67 |
+
if [[ -z "$JTBIN" || ! -d "$JTBIN" || "$JTBIN" = "$DST/release" ]]; then
|
| 68 |
+
echo "\$JTBIN is not well defined"
|
| 69 |
+
return 1
|
| 70 |
+
fi
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
get_valid_zip() {
|
| 74 |
+
local hash="$1"
|
| 75 |
+
local ref
|
| 76 |
+
if [ -z "$hash" ]; then
|
| 77 |
+
echo "Use jtrelease.sh git-hash"
|
| 78 |
+
return 1
|
| 79 |
+
fi
|
| 80 |
+
|
| 81 |
+
ref=${JTBUILDS}/${hash:0:7}.zip
|
| 82 |
+
if [ ! -e $ref ]; then
|
| 83 |
+
echo "path $ref failed" >&2
|
| 84 |
+
ref=${JTBUILDS}/mister_${hash:0:7}.zip;
|
| 85 |
+
fi
|
| 86 |
+
|
| 87 |
+
if [ ! -e $ref ]; then
|
| 88 |
+
echo "No build ${hash:0:7} available" >&2
|
| 89 |
+
echo "Tried path: `pwd`/$ref" >&2
|
| 90 |
+
return 125
|
| 91 |
+
fi
|
| 92 |
+
|
| 93 |
+
echo $ref
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
clone_repo() {
|
| 97 |
+
local hash="$1"
|
| 98 |
+
local path="$2"
|
| 99 |
+
set --
|
| 100 |
+
git clone $JTROOT $path
|
| 101 |
+
cd $path
|
| 102 |
+
git checkout $hash
|
| 103 |
+
source setprj.sh
|
| 104 |
+
cd $path
|
| 105 |
+
git submodule init $JTFRAME/target/pocket
|
| 106 |
+
git submodule update --depth 1 $JTFRAME/target/pocket
|
| 107 |
+
git submodule init modules/jt51
|
| 108 |
+
git submodule update --depth 1 modules/jt51
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
get_full_hash() {
|
| 112 |
+
git rev-parse HEAD
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
recompile_tool() {
|
| 116 |
+
local toolname="jtframe"
|
| 117 |
+
local tmplog=`mktemp`
|
| 118 |
+
local status=0
|
| 119 |
+
cd $JTFRAME/src/$toolname
|
| 120 |
+
go mod tidy
|
| 121 |
+
if ! $toolname > $tmplog; then
|
| 122 |
+
cat $tmplog
|
| 123 |
+
status=1
|
| 124 |
+
fi
|
| 125 |
+
rm $tmplog
|
| 126 |
+
return $status
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
unzip_release() {
|
| 130 |
+
local zipfile="$1"
|
| 131 |
+
local path="$2"
|
| 132 |
+
cd $path
|
| 133 |
+
echo "Unzipping $zipfile"
|
| 134 |
+
unzip -q $zipfile -d release
|
| 135 |
+
if [ -d release/release ]; then mv release/release/* release; rmdir release/release; fi
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
clean_jtbin() {
|
| 139 |
+
if [ ! -d .git ]; then return; fi
|
| 140 |
+
git reset --hard
|
| 141 |
+
git clean -fd .
|
| 142 |
+
git checkout master
|
| 143 |
+
rm -rf mist sidi* pocket mister mra
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
refresh_schematics() {
|
| 147 |
+
echo "Refreshing schematics"
|
| 148 |
+
jtframe sch --git
|
| 149 |
+
echo "Deleting non-arcade PCB schematics"
|
| 150 |
+
rm -f $JTBIN/sch/{adapter,odyssey,rng}.pdf
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
regenerate_mra() {
|
| 154 |
+
rm -rf release/mra
|
| 155 |
+
find release/pocket -name "*rbf_r" | xargs -I% basename % .rbf_r | sort | uniq | sed s/^jt// > pocket.cores
|
| 156 |
+
find release/{mister,sidi,sidi128,mist} -name "*rbf" | xargs -I% basename % .rbf | sort | uniq | sed s/^jt// | sort > mister.cores
|
| 157 |
+
jtframe mra $SKIPROM --md5 --git `cat pocket.cores` --nodbg
|
| 158 |
+
comm -3 pocket.cores mister.cores > other.cores
|
| 159 |
+
sed -i '/neogeopocket/d' other.cores
|
| 160 |
+
if [ `wc -l other.cores|cut -f1 -d' '` -gt 0 ]; then
|
| 161 |
+
# cat other.cores
|
| 162 |
+
jtframe mra $SKIPROM --md5 --skipPocket --git `cat other.cores` --nodbg
|
| 163 |
+
fi
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
copy_rbf() {
|
| 167 |
+
local repo="$1"
|
| 168 |
+
local curfolder=$(basename $(pwd))
|
| 169 |
+
echo "Copy release files to $curfolder"
|
| 170 |
+
cp -r $repo/release/* .
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
make_all_pocket_zips() {
|
| 174 |
+
echo "Making Pocket zip files"
|
| 175 |
+
mkdir -p $JTBIN/pocket/zips
|
| 176 |
+
for core in `find pocket/raw -name "*.rbf_r"`; do
|
| 177 |
+
core=`basename $core .rbf_r`
|
| 178 |
+
pocket_zip $core
|
| 179 |
+
done
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
make_md5_reference_file() {
|
| 183 |
+
jtutil md5
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
pocket_zip() {
|
| 187 |
+
local corename="$1"
|
| 188 |
+
cd $JTBIN/pocket/raw
|
| 189 |
+
zip -qr jotego.${corename}.zip ${corename}.txt Assets/${corename} Cores/jotego.${corename} \
|
| 190 |
+
Platforms/${corename}.json Platforms/_images/${corename}.bin Presets/jotego.${corename} Saves/${corename}
|
| 191 |
+
mv jotego.${corename}.zip $JTBIN/pocket/zips
|
| 192 |
+
cd - > /dev/null
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
remove_mist_betas() {
|
| 196 |
+
echo "Removing games in beta phase for SiDi and MiST"
|
| 197 |
+
for t in mist sidi sidi128; do
|
| 198 |
+
for rbf in $JTBIN/$t/*.rbf; do
|
| 199 |
+
corename=`basename $rbf .rbf`
|
| 200 |
+
if jtframe cfgstr ${corename#jt} -o bash -t mister | grep JTFRAME_UNLOCKKEY > /dev/null; then
|
| 201 |
+
rm -v $rbf;
|
| 202 |
+
fi
|
| 203 |
+
done
|
| 204 |
+
done
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
make_game_list() {
|
| 208 |
+
jtutil mra --core > $JTBIN/game_list.md
|
| 209 |
+
jtutil mra --core --main-only > $JTBIN/only_main_titles.md
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
make_pocket_beta_helper() {
|
| 213 |
+
mkdir -p pocket/raw/Assets/jtpatreon/common
|
| 214 |
+
echo "beta.bin goes here" > pocket/raw/Assets/jtpatreon/common/BETABIN_GOES_HERE
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
make_sound_balance_audit() {
|
| 218 |
+
jtutil audit
|
| 219 |
+
mv audit.csv sound_balance.csv
|
| 220 |
+
git add sound_balance.csv
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
commit_release() {
|
| 224 |
+
echo "Commit to git"
|
| 225 |
+
git add .
|
| 226 |
+
git commit -m "release for https://github.com/jotego/jtcores/commit/$HASHLONG"
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
tag_release_in_jtcores() {
|
| 230 |
+
cd $JTROOT
|
| 231 |
+
(git tag -f JTBIN && git push --tags --force) || echo "Could not tag the release on jtcores"
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
show_md5_diff() {
|
| 235 |
+
cd $JTBIN
|
| 236 |
+
git show HEAD^1:md5.json > old.json
|
| 237 |
+
jtutil md5 --compare old.json || true
|
| 238 |
+
rm -f old.json
|
| 239 |
+
}
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtrelease.sh
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -e
|
| 2 |
+
# Make a release to JTBIN from GitHub builds
|
| 3 |
+
|
| 4 |
+
source jtrelease-funcs
|
| 5 |
+
|
| 6 |
+
trap clean_up ERR
|
| 7 |
+
|
| 8 |
+
parse_args $*
|
| 9 |
+
check_jtbin
|
| 10 |
+
|
| 11 |
+
REF=`get_valid_zip $HASH`
|
| 12 |
+
DST=`mktemp -d /tmp/jt_XXXXXX`
|
| 13 |
+
|
| 14 |
+
clone_repo $HASH $DST
|
| 15 |
+
HASHLONG=`get_full_hash`
|
| 16 |
+
|
| 17 |
+
recompile_tool jtframe
|
| 18 |
+
recompile_tool jtutil
|
| 19 |
+
unzip_release $REF $DST
|
| 20 |
+
|
| 21 |
+
echo "Copying to $JTBIN"
|
| 22 |
+
cd $JTBIN
|
| 23 |
+
clean_jtbin
|
| 24 |
+
refresh_schematics
|
| 25 |
+
|
| 26 |
+
cd $DST
|
| 27 |
+
regenerate_mra
|
| 28 |
+
cd $JTBIN
|
| 29 |
+
copy_rbf $DST
|
| 30 |
+
make_all_pocket_zips
|
| 31 |
+
make_md5_reference_file
|
| 32 |
+
# note that the beta zip files are generated before deleting
|
| 33 |
+
# the mist and sidi beta files from JTBIN
|
| 34 |
+
cpbeta.sh $LAST
|
| 35 |
+
remove_mist_betas
|
| 36 |
+
make_game_list
|
| 37 |
+
make_sound_balance_audit
|
| 38 |
+
make_pocket_beta_helper
|
| 39 |
+
commit_release
|
| 40 |
+
tag_release_in_jtcores
|
| 41 |
+
clean_up
|
| 42 |
+
show_md5_diff
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtsdram
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
echo SDRAM_SHIFT macro is currently disabled in MiSTer pll_0002.v file
|
| 4 |
+
echo enabled it and fixed the SHIFTS variable in this script. Before running
|
| 5 |
+
echo the script again.
|
| 6 |
+
exit 1
|
| 7 |
+
|
| 8 |
+
MIN=-11000
|
| 9 |
+
MAX=11000
|
| 10 |
+
CORE=
|
| 11 |
+
EXTRA=
|
| 12 |
+
DRYRUN=
|
| 13 |
+
MRA=
|
| 14 |
+
SKIP=0
|
| 15 |
+
|
| 16 |
+
SHIFTS="12500 6510 8506 9765 10503 2994 1736 729 5000 1041 1996 3993 10000 5989 7986 11024 8984 11979 260 1250 2256 3515 3750 4253 520 4774 5208 10243 9505 10329 9244 10763 8750 11284 8246 7725 7500 1475 4513 7291 6979 11458 6770 5520 2734 6250 3255 11770 2500 5729 12239"
|
| 17 |
+
|
| 18 |
+
while [ $# -gt 0 ]; do
|
| 19 |
+
case "$1" in
|
| 20 |
+
-mra)
|
| 21 |
+
shift
|
| 22 |
+
MRA=$1;;
|
| 23 |
+
-skip)
|
| 24 |
+
SKIP=1;;
|
| 25 |
+
-min)
|
| 26 |
+
shift
|
| 27 |
+
MIN=$1;;
|
| 28 |
+
-max)
|
| 29 |
+
shift
|
| 30 |
+
MAX=$1;;
|
| 31 |
+
-core)
|
| 32 |
+
shift
|
| 33 |
+
CORE=$1;;
|
| 34 |
+
-96)
|
| 35 |
+
echo "96MHz clock selected"
|
| 36 |
+
SHIFTS="-520 -1041 -1475 -1996 -2517 -2994 -3515 -3993 -4253 -4513 -4774 -5034 -5208"
|
| 37 |
+
;;
|
| 38 |
+
-dryrun)
|
| 39 |
+
DRYRUN=echo;;
|
| 40 |
+
-h|-help)
|
| 41 |
+
echo Usage: jtseed -core "<name>" "[-min value]" "-max [value]" "[-96] [-dryrun] : [args for jtcore]"
|
| 42 |
+
echo -96 : enable 96MHz shift values
|
| 43 |
+
echo -dryrun: show commands without executing them
|
| 44 |
+
echo Valid delays for 48MHz:
|
| 45 |
+
echo 0 260 520 729 1041 1250 1475 1736 1996 2256 2500 2734 2994 3255 3515 3750 3993
|
| 46 |
+
echo 4253 4513 4774 5000 5208 5520 5729 5989 6250 6510 6770 6979 7291 7500 7725 7986
|
| 47 |
+
echo 8246 8506 8750 8984 9244 9505 9765 10000 10243 10329
|
| 48 |
+
echo 10503 10763 11024 11284 11458 11770 11979 12239 12500
|
| 49 |
+
echo
|
| 50 |
+
echo Valid delays for 96MHz:
|
| 51 |
+
echo "0 -520 -1041 -1475 -1996 -2517 -2994 -3515 -3993"
|
| 52 |
+
exit 0
|
| 53 |
+
;;
|
| 54 |
+
:)
|
| 55 |
+
shift
|
| 56 |
+
EXTRA="$*"
|
| 57 |
+
break
|
| 58 |
+
;;
|
| 59 |
+
*)
|
| 60 |
+
echo "Unknown parameter $1"
|
| 61 |
+
exit 1;;
|
| 62 |
+
esac
|
| 63 |
+
shift
|
| 64 |
+
done
|
| 65 |
+
|
| 66 |
+
if [ -z "$CORE" ]; then
|
| 67 |
+
echo "Must give corename with -core option"
|
| 68 |
+
exit 1
|
| 69 |
+
fi
|
| 70 |
+
|
| 71 |
+
CORE_DIR=$JTROOT
|
| 72 |
+
|
| 73 |
+
if [ -d $JTROOT/cores/$CORE ];then
|
| 74 |
+
CORE_DIR=$JTROOT/cores/$CORE
|
| 75 |
+
fi
|
| 76 |
+
|
| 77 |
+
for DELAY in $SHIFTS;
|
| 78 |
+
do
|
| 79 |
+
if [[ $DELAY -lt $MIN || $DELAY -gt $MAX ]]; then
|
| 80 |
+
continue
|
| 81 |
+
fi
|
| 82 |
+
if [ $SKIP = 0 ]; then
|
| 83 |
+
echo Using ${DELAY}ps delay
|
| 84 |
+
$DRYRUN jtcore ${CORE} -mr -d SDRAM_SHIFT=\\\"$DELAY\\\" $EXTRA
|
| 85 |
+
fi
|
| 86 |
+
if [ -e "$MRA" ]; then
|
| 87 |
+
MRANAME=$(basename $MRA .mra)_${DELAY}ps.mra
|
| 88 |
+
$DRYRUN cp $MRA $MRANAME
|
| 89 |
+
$DRYRUN sed -i s/jt${CORE}/jt${CORE}_${DELAY}ps/ $MRANAME
|
| 90 |
+
fi
|
| 91 |
+
if [[ -n "$DRYRUN" || $SKIP = 1 ]]; then
|
| 92 |
+
continue
|
| 93 |
+
fi
|
| 94 |
+
OUTPUT=$CORE_DIR/mister/output_1/jt${CORE}.rbf
|
| 95 |
+
if [ -e $OUTPUT ]; then
|
| 96 |
+
cp $OUTPUT jt${CORE}_${DELAY}ps.rbf
|
| 97 |
+
mv $JTROOT/log/mister/jt${CORE}.log jt${CORE}_${DELAY}ps.log
|
| 98 |
+
else
|
| 99 |
+
echo "Missing output RBF file for ${DELAY}ps"
|
| 100 |
+
exit 1
|
| 101 |
+
fi
|
| 102 |
+
done
|
| 103 |
+
|
| 104 |
+
if [ $SKIP = 0 ]; then
|
| 105 |
+
$DRYRUN 7za a jt${CORE}_shift.7z jt${CORE}*.log jt${CORE}*.rbf
|
| 106 |
+
fi
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtseed
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# This file is part of JTFRAME.
|
| 3 |
+
# JTFRAME program is free software: you can redistribute it and/or modify
|
| 4 |
+
# it under the terms of the GNU General Public License as published by
|
| 5 |
+
# the Free Software Foundation, either version 3 of the License, or
|
| 6 |
+
# (at your option) any later version.
|
| 7 |
+
|
| 8 |
+
# JTFRAME program is distributed in the hope that it will be useful,
|
| 9 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 10 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 11 |
+
# GNU General Public License for more details.
|
| 12 |
+
|
| 13 |
+
# You should have received a copy of the GNU General Public License
|
| 14 |
+
# along with JTFRAME. If not, see <http://www.gnu.org/licenses/>.
|
| 15 |
+
|
| 16 |
+
# Author: Jose Tejada Gomez. Twitter: @topapate
|
| 17 |
+
# Version: 1.0
|
| 18 |
+
# Date: 5-11-2022
|
| 19 |
+
|
| 20 |
+
echo "Create a jtseed.last file at this folder to stop at the next compilation"
|
| 21 |
+
|
| 22 |
+
rm -f jtseed.last
|
| 23 |
+
|
| 24 |
+
MAXREPS=100
|
| 25 |
+
SEED=0
|
| 26 |
+
|
| 27 |
+
re='^[0-9]+$'
|
| 28 |
+
if [[ $1 =~ $re && $1 != 194? ]] ; then
|
| 29 |
+
MAXREPS=$1
|
| 30 |
+
shift
|
| 31 |
+
else
|
| 32 |
+
echo "Call jtseed with a number as the first argument to limit the iterations"
|
| 33 |
+
fi
|
| 34 |
+
|
| 35 |
+
for i in $*; do
|
| 36 |
+
if [ $i = -s ]; then
|
| 37 |
+
echo "Error: cannot invoke jtseed with the -s (skip) option"
|
| 38 |
+
exit 1
|
| 39 |
+
fi
|
| 40 |
+
done
|
| 41 |
+
|
| 42 |
+
while [ $MAXREPS -gt 0 ]; do
|
| 43 |
+
if jtcore $* --seed $SEED; then
|
| 44 |
+
break
|
| 45 |
+
fi
|
| 46 |
+
# parallel jtcore $* -seed {} ::: $RANDOM $RANDOM | tee -a $1_seed.log
|
| 47 |
+
if [ -e jtseed.last ]; then
|
| 48 |
+
rm jtseed.last
|
| 49 |
+
exit 0
|
| 50 |
+
fi
|
| 51 |
+
SEED=$RANDOM
|
| 52 |
+
MAXREPS=$((MAXREPS-1))
|
| 53 |
+
done
|
| 54 |
+
|
| 55 |
+
if [ $MAXREPS = 0 ]; then
|
| 56 |
+
# aborted before completing because of reaching the iteration limit
|
| 57 |
+
echo Maximum number of seed trial reached
|
| 58 |
+
exit 1
|
| 59 |
+
fi
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtsim
ADDED
|
@@ -0,0 +1,556 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# This file is part of JT_FRAME.
|
| 4 |
+
# JTFRAME program is free software: you can redistribute it and/or modify
|
| 5 |
+
# it under the terms of the GNU General Public License as published by
|
| 6 |
+
# the Free Software Foundation, either version 3 of the License, or
|
| 7 |
+
# (at your option) any later version.
|
| 8 |
+
#
|
| 9 |
+
# JTFRAME program is distributed in the hope that it will be useful,
|
| 10 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 11 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 12 |
+
# GNU General Public License for more details.
|
| 13 |
+
#
|
| 14 |
+
# You should have received a copy of the GNU General Public License
|
| 15 |
+
# along with JTFRAME. If not, see <http://www.gnu.org/licenses/>.
|
| 16 |
+
#
|
| 17 |
+
# Author: Jose Tejada Gomez. Twitter: @topapate
|
| 18 |
+
# Date: 20-8-2022
|
| 19 |
+
|
| 20 |
+
source $JTFRAME/bin/jtsim-funcs
|
| 21 |
+
|
| 22 |
+
define_terminal_colors
|
| 23 |
+
|
| 24 |
+
COV=
|
| 25 |
+
DIR=
|
| 26 |
+
DUMP=
|
| 27 |
+
SIM_MS=1
|
| 28 |
+
SIMARGS="-f core.def -f filtered.f"
|
| 29 |
+
SIMULATOR=verilator
|
| 30 |
+
SETNAME=
|
| 31 |
+
SKIPROM=
|
| 32 |
+
TOP=game_test
|
| 33 |
+
TARGET=
|
| 34 |
+
FILES=
|
| 35 |
+
MACROPREFIX=+define+
|
| 36 |
+
# All command line macros separated by commas, this is used
|
| 37 |
+
# in calls to jtframe
|
| 38 |
+
ALLMACROS=
|
| 39 |
+
BATCH=
|
| 40 |
+
VERILATOR_SAFE=
|
| 41 |
+
EXTRA=
|
| 42 |
+
SHOWCMD=
|
| 43 |
+
ARGNUMBER=1
|
| 44 |
+
SAMPLING_RATE=
|
| 45 |
+
TESTCPP=
|
| 46 |
+
GATES=NO
|
| 47 |
+
MACOS=NO
|
| 48 |
+
KEEP_FX68K=
|
| 49 |
+
SED="sed -i"
|
| 50 |
+
SHAUP=
|
| 51 |
+
FRAMERATE=
|
| 52 |
+
START_TIME=$(date +%s)
|
| 53 |
+
UNDEF=
|
| 54 |
+
FAST=
|
| 55 |
+
# Extra arguments for the simulator, passed with -args
|
| 56 |
+
SIMULATOR_EXTRA=
|
| 57 |
+
|
| 58 |
+
# sed and stat are different for MacOS and GNU
|
| 59 |
+
if [ `uname` = Darwin ]; then
|
| 60 |
+
MACOS=YES
|
| 61 |
+
# BSD version for sed command
|
| 62 |
+
if ! sed --version > /dev/null; then
|
| 63 |
+
SED="sed -i bak"
|
| 64 |
+
fi
|
| 65 |
+
fi
|
| 66 |
+
|
| 67 |
+
# set blank .f files
|
| 68 |
+
echo -n > jtsim_vhdl.f
|
| 69 |
+
echo -n > jtsim.f
|
| 70 |
+
|
| 71 |
+
trap "clean_up; exit 1" INT KILL
|
| 72 |
+
|
| 73 |
+
preparse_args $*
|
| 74 |
+
require "$JTFRAME" "You need to source the project setprj.sh"
|
| 75 |
+
require "$MODULES" "Missing the modules path. You need to source the project setprj.sh"
|
| 76 |
+
|
| 77 |
+
if ! has_parent ver; then
|
| 78 |
+
echo "jtsim must be called from within the ver folder of the core"
|
| 79 |
+
exit 1
|
| 80 |
+
fi
|
| 81 |
+
|
| 82 |
+
while [ $# -gt 0 ]; do
|
| 83 |
+
case "$1" in
|
| 84 |
+
-args) shift; SIMULATOR_EXTRA="$SIMULATOR_EXTRA $1";;
|
| 85 |
+
-batch) BATCH=1;;
|
| 86 |
+
-cov) COV=--coverage;;
|
| 87 |
+
-debug_bus) shift; add_macro "JTFRAME_SIM_DEBUG=$1";;
|
| 88 |
+
-fx68k) KEEP_FX68K=1;;
|
| 89 |
+
-showcmd) SHOWCMD="echo";;
|
| 90 |
+
-modules) shift;; # ignore here
|
| 91 |
+
-w | -deep)
|
| 92 |
+
add_macro DUMP
|
| 93 |
+
DUMP=1
|
| 94 |
+
if [ $1 = "-deep" ]; then add_macro DEEPDUMP; fi
|
| 95 |
+
if [[ $2 =~ ^[0-9]+$ ]]; then
|
| 96 |
+
# you can specify at which frame the dumping starts
|
| 97 |
+
# right after -w or -deep
|
| 98 |
+
shift
|
| 99 |
+
add_macro DUMP_START=$1
|
| 100 |
+
fi
|
| 101 |
+
;;
|
| 102 |
+
######## Macros
|
| 103 |
+
-d) shift
|
| 104 |
+
add_macro $1;;
|
| 105 |
+
-u|-undef) shift
|
| 106 |
+
if [ ! -z "$UNDEF" ]; then UNDEF="$UNDEF,"; fi
|
| 107 |
+
UNDEF="$UNDEF$1";;
|
| 108 |
+
-dir)
|
| 109 |
+
DIR=1
|
| 110 |
+
;;
|
| 111 |
+
-dipsw)
|
| 112 |
+
shift
|
| 113 |
+
add_macro JTFRAME_SIM_DIPS=0x${1#0x};;
|
| 114 |
+
-dump)
|
| 115 |
+
shift
|
| 116 |
+
add_macro "JTFRAME_SIM_IODUMP=$1";;
|
| 117 |
+
-test)
|
| 118 |
+
add_macro DIP_TEST;;
|
| 119 |
+
-gates)
|
| 120 |
+
GATES=YES
|
| 121 |
+
if [ $SIMULATOR = verilator ]; then
|
| 122 |
+
echo "${rBG}Error:${NC} Verilator cannot be used for gate-level sims"
|
| 123 |
+
exit 1
|
| 124 |
+
fi
|
| 125 |
+
;;
|
| 126 |
+
-gfx)
|
| 127 |
+
shift
|
| 128 |
+
add_macro JTFRAME_SIM_GFXEN=0x${1#0x};;
|
| 129 |
+
-fast) FAST=1;;
|
| 130 |
+
-frate)
|
| 131 |
+
shift
|
| 132 |
+
FRAMERATE=$1
|
| 133 |
+
add_macro JTFRAME_SIM_VIDEO;;
|
| 134 |
+
-inputs)
|
| 135 |
+
if [[ $2 != -* ]]; then
|
| 136 |
+
shift
|
| 137 |
+
if [ ! -e "$1" ]; then
|
| 138 |
+
echo "Error: cannot find input file $1"
|
| 139 |
+
exit 1
|
| 140 |
+
fi
|
| 141 |
+
if [[ "$1" == *.cab ]]; then
|
| 142 |
+
jtframe cab "$1" || exit $?
|
| 143 |
+
else
|
| 144 |
+
cp "$1" sim_inputs.hex
|
| 145 |
+
fi
|
| 146 |
+
elif [ ! -e sim_inputs.hex ]; then
|
| 147 |
+
echo "-inputs specified but there is no sim_inputs.hex file"
|
| 148 |
+
exit 1
|
| 149 |
+
fi
|
| 150 |
+
add_macro SIM_INPUTS;;
|
| 151 |
+
-keepcpp)
|
| 152 |
+
shift
|
| 153 |
+
TESTCPP=KEEP
|
| 154 |
+
;;
|
| 155 |
+
-pause)
|
| 156 |
+
add_macro DIP_PAUSE;;
|
| 157 |
+
-frame)
|
| 158 |
+
shift
|
| 159 |
+
if [ "$1" = "" ]; then
|
| 160 |
+
echo "${rBG}Error:${NC} Must specify the number of frames to simulate"
|
| 161 |
+
exit 1
|
| 162 |
+
fi
|
| 163 |
+
add_macro MAXFRAME=$1
|
| 164 |
+
echo Simulate up to $1 frames
|
| 165 |
+
;;
|
| 166 |
+
-skipROM) SKIPROM="--skipROM";;
|
| 167 |
+
-srate)
|
| 168 |
+
shift
|
| 169 |
+
if [ "$1" = "" ]; then
|
| 170 |
+
echo "${rBG}Error:${NC} Must specify the sampling rate"
|
| 171 |
+
exit 1
|
| 172 |
+
fi
|
| 173 |
+
SAMPLING_RATE="-s $1"
|
| 174 |
+
;;
|
| 175 |
+
#################### Pocket setup
|
| 176 |
+
-pocket)
|
| 177 |
+
TOP=test
|
| 178 |
+
TARGET=pocket
|
| 179 |
+
;;
|
| 180 |
+
#################### MiST setup
|
| 181 |
+
-mist) set_mist_as_target;;
|
| 182 |
+
-sidi128) set_sidi128_as_target;;
|
| 183 |
+
#################### MiSTer setup
|
| 184 |
+
-mister|-mr)
|
| 185 |
+
TOP=mister_test
|
| 186 |
+
TARGET=mister
|
| 187 |
+
# Generate a fake build_id.v file
|
| 188 |
+
echo "\`define BUILD_DATE \"190311\"" > build_id.v
|
| 189 |
+
echo "\`define BUILD_TIME \"190311\"" >> build_id.v
|
| 190 |
+
;;
|
| 191 |
+
##########################
|
| 192 |
+
-nosnd|-q)
|
| 193 |
+
add_macro NOSOUND
|
| 194 |
+
add_macro NOFM
|
| 195 |
+
add_macro NOSSG;;
|
| 196 |
+
-setname)
|
| 197 |
+
shift
|
| 198 |
+
SETNAME=$1;;
|
| 199 |
+
-s|-scene)
|
| 200 |
+
shift
|
| 201 |
+
SCENE="$1/dump.bin"
|
| 202 |
+
if [ ! -e "$SCENE" ]; then
|
| 203 |
+
SCENE="scenes/$SCENE"
|
| 204 |
+
fi
|
| 205 |
+
if [[ -e "$SCENE" && -x ../game/dump2bin.sh ]]; then
|
| 206 |
+
../game/dump2bin.sh "$SCENE" 2> /dev/null
|
| 207 |
+
add_macro NOMAIN NOSOUND DUMP DUMP_VIDEO MAXFRAME=3 SIMSCENE
|
| 208 |
+
set_zoom
|
| 209 |
+
rm -rf video.bin frame_*.jpg frame.raw frames
|
| 210 |
+
VIDEO_DUMP=TRUE
|
| 211 |
+
else
|
| 212 |
+
echo "Scene file $SCENE or dump2bin.sh were not found"
|
| 213 |
+
exit 1
|
| 214 |
+
fi
|
| 215 |
+
;;
|
| 216 |
+
-shaup) SHAUP=1;;
|
| 217 |
+
-time)
|
| 218 |
+
shift
|
| 219 |
+
if [ "$1" = "" ]; then
|
| 220 |
+
echo "${rBG}Error:${NC} Must specify number of milliseconds to simulate"
|
| 221 |
+
exit 1
|
| 222 |
+
fi
|
| 223 |
+
SIM_MS="$1"
|
| 224 |
+
echo Simulate $1 ms
|
| 225 |
+
;;
|
| 226 |
+
-safe)
|
| 227 |
+
VERILATOR_SAFE=-fno-dfg-peephole;;
|
| 228 |
+
-stats)
|
| 229 |
+
add_macro JTFRAME_SDRAM_STATS
|
| 230 |
+
echo RAM stats enabled
|
| 231 |
+
;;
|
| 232 |
+
-video)
|
| 233 |
+
add_macro DUMP_VIDEO
|
| 234 |
+
if [ "${2:0:1}" != - ]; then
|
| 235 |
+
# get number of frames to simulate
|
| 236 |
+
shift
|
| 237 |
+
add_macro MAXFRAME=$1
|
| 238 |
+
fi
|
| 239 |
+
rm -rf video.bin frame_*.jpg frame.raw frames
|
| 240 |
+
VIDEO_DUMP=TRUE
|
| 241 |
+
;;
|
| 242 |
+
-load)
|
| 243 |
+
enable_load
|
| 244 |
+
;;
|
| 245 |
+
-lint)
|
| 246 |
+
# only possible with verilator
|
| 247 |
+
EXTRA="$EXTRA --lint-only -Wno-REDEFMACRO -Wno-UNOPTFLAT"
|
| 248 |
+
add_macro LINT
|
| 249 |
+
export LINT=1
|
| 250 |
+
;;
|
| 251 |
+
-ncverilog|-verilator|-synap|-modelsim|-iverilog|-questasim|-xcelium)
|
| 252 |
+
# This is parsed in the first argument loop
|
| 253 |
+
;;
|
| 254 |
+
-help|-h|--help)
|
| 255 |
+
show_help
|
| 256 |
+
exit 0;;
|
| 257 |
+
-zoom) set_zoom;; # export it for Verilator's test.cpp
|
| 258 |
+
*) echo "${rBG}Error:${NC} Unknown option $1. Use -help to see the list of options"; exit 1;;
|
| 259 |
+
esac
|
| 260 |
+
shift
|
| 261 |
+
ARGNUMBER=$((ARGNUMBER+1))
|
| 262 |
+
done
|
| 263 |
+
|
| 264 |
+
if [ -z "$TARGET" ]; then
|
| 265 |
+
set_sidi128_as_target
|
| 266 |
+
fi
|
| 267 |
+
|
| 268 |
+
SYSNAME=`derive_corename_from_folder`
|
| 269 |
+
|
| 270 |
+
mkdir -p frames
|
| 271 |
+
require "$SYSNAME" "Missing core name. Run jtsim for a cores/corename/ver/setname folder"
|
| 272 |
+
|
| 273 |
+
# Load a specific rom set
|
| 274 |
+
if [ ! -z "$SETNAME" ]; then
|
| 275 |
+
use_setname
|
| 276 |
+
else
|
| 277 |
+
SETNAME=`derive_setname_from_folder`
|
| 278 |
+
fi
|
| 279 |
+
|
| 280 |
+
if [ $SETNAME = game ]; then
|
| 281 |
+
unset SETNAME
|
| 282 |
+
echo "Specify a valid ROM set name or run jtsim from a folder in ver/setname"
|
| 283 |
+
exit 1
|
| 284 |
+
fi
|
| 285 |
+
|
| 286 |
+
|
| 287 |
+
echo "${wBG}=========== JTSIM $SYSNAME $SETNAME ($TARGET) ===========${NC}" > /dev/stderr
|
| 288 |
+
warn_if_longsim_noinputs
|
| 289 |
+
|
| 290 |
+
if ! has_macro JTFRAME_SIM_DIPS; then
|
| 291 |
+
get_default_dipsw $SETNAME
|
| 292 |
+
fi
|
| 293 |
+
|
| 294 |
+
copy_mod_file $SETNAME
|
| 295 |
+
if [[ ! -s rom.bin && -z "$LINT" ]]; then
|
| 296 |
+
make_rombin_link $SETNAME
|
| 297 |
+
fi
|
| 298 |
+
add_macro GAME_ROM_LEN=`get_file_length rom.bin`
|
| 299 |
+
|
| 300 |
+
# Add a local copy of the dump file if it doesn't exist
|
| 301 |
+
if [ ! -e ${TARGET}_dump.v ]; then
|
| 302 |
+
cp $JTFRAME/target/$TARGET/ver/${TARGET}_dump.v .
|
| 303 |
+
fi
|
| 304 |
+
FILES="$FILES ${TARGET}_dump.v"
|
| 305 |
+
|
| 306 |
+
if [ ! -z "$EXTRA" ]; then
|
| 307 |
+
echo Verilog macros: "$EXTRA"
|
| 308 |
+
fi
|
| 309 |
+
|
| 310 |
+
if [ ! -z "$MEM_CHECK_TIME" ]; then
|
| 311 |
+
add_macro MEM_CHECK_TIME=$MEM_CHECK_TIME
|
| 312 |
+
fi
|
| 313 |
+
|
| 314 |
+
# Common macros
|
| 315 |
+
add_macro SIM_MS=$SIM_MS
|
| 316 |
+
add_macro SIMULATION
|
| 317 |
+
add_macro $(echo $SIMULATOR | tr '[:lower:]' '[:upper:]')
|
| 318 |
+
|
| 319 |
+
# Parse the core .def file
|
| 320 |
+
if ! jtcfgstr $SIMULATOR > core.def; then
|
| 321 |
+
cat core.def
|
| 322 |
+
exit 1
|
| 323 |
+
fi
|
| 324 |
+
|
| 325 |
+
disable_patreon_credits
|
| 326 |
+
|
| 327 |
+
# Verilator macros
|
| 328 |
+
if ! jtcfgstr cpp > defmacros.h ; then
|
| 329 |
+
cat defmacros.h
|
| 330 |
+
exit 1
|
| 331 |
+
fi
|
| 332 |
+
|
| 333 |
+
# Get the macros in cfg/macros.def into bash
|
| 334 |
+
eval `jtcfgstr bash`
|
| 335 |
+
|
| 336 |
+
if [ -z "$GAMETOP" ]; then
|
| 337 |
+
GAMETOP=${CORENAME,,}_game
|
| 338 |
+
echo Using $GAMETOP as top module
|
| 339 |
+
fi
|
| 340 |
+
|
| 341 |
+
# Non Verilator sims do image conversion via raw2png
|
| 342 |
+
if [[ "$VIDEO_DUMP" = TRUE && $SIMULATOR != verilator ]]; then
|
| 343 |
+
rm -f video.pipe
|
| 344 |
+
mkfifo video.pipe
|
| 345 |
+
raw2png -w $JTFRAME_WIDTH -h $JTFRAME_HEIGHT -f video.pipe : $CONVERT_OPTIONS&
|
| 346 |
+
fi
|
| 347 |
+
|
| 348 |
+
# Link to hex files in HDL folder
|
| 349 |
+
for i in $CORES/$SYSNAME/hdl/*.hex; do
|
| 350 |
+
if [ -e $i ]; then
|
| 351 |
+
ln -fs $i $(basename $i)
|
| 352 |
+
fi
|
| 353 |
+
done
|
| 354 |
+
|
| 355 |
+
if [ $GATES = NO ]; then
|
| 356 |
+
# Prepare all file lists
|
| 357 |
+
jtframe mem $SYSNAME --target "$TARGET" --local || exit $?
|
| 358 |
+
jtframe mmr $SYSNAME || exit $?
|
| 359 |
+
jtframe files sim $SYSNAME --rel --local --target "$TARGET" --macro "$ALLMACROS" || exit $?
|
| 360 |
+
if grep --quiet fx68k game.f; then
|
| 361 |
+
# These files are read by the FX68K module but they must be in the
|
| 362 |
+
# simulation folder. Forgetting to have them there results in X everywhere
|
| 363 |
+
ln -sfr $MODULES/fx68k/hdl/microrom.mem
|
| 364 |
+
ln -sfr $MODULES/fx68k/hdl/nanorom.mem
|
| 365 |
+
fi
|
| 366 |
+
# Remove duplicated lines
|
| 367 |
+
rm -f tmp.f
|
| 368 |
+
rm -f game_env.f
|
| 369 |
+
# Simulator-specific needs
|
| 370 |
+
case $SIMULATOR in
|
| 371 |
+
verilator)
|
| 372 |
+
$SED "/\.vhd/d" game.f
|
| 373 |
+
$SED "/\.qip/d" game.f;;
|
| 374 |
+
modelsim|questasim)
|
| 375 |
+
# ' induces new line by modelsim
|
| 376 |
+
$SED "s/'h/\\\\'h/g" core.def;;
|
| 377 |
+
iverilog)
|
| 378 |
+
if [ ! -z "$KEEP_FX68K" ]; then
|
| 379 |
+
# Remove references to fx68k as it is not supported in iverilog
|
| 380 |
+
$SED /fx68k/d game.f
|
| 381 |
+
fi;;
|
| 382 |
+
esac
|
| 383 |
+
cat game.f jtsim.f >> tmp.f
|
| 384 |
+
cat tmp.f | envsubst | grep -v "^#" | xargs realpath --relative-to=. | sort | uniq > game_env.f
|
| 385 |
+
# Sort and delete duplicates
|
| 386 |
+
emulate_F game_env.f | sort | uniq > filtered.f
|
| 387 |
+
rm -f game_env.f tmp.f
|
| 388 |
+
else
|
| 389 |
+
prepare_gatelevel_sim
|
| 390 |
+
fi
|
| 391 |
+
|
| 392 |
+
# Link to hex filters in module files as needed
|
| 393 |
+
if grep -q jtframe_jt49_filters filtered.f; then
|
| 394 |
+
ln -srf $JTFRAME/hdl/sound/firjt49.hex
|
| 395 |
+
fi
|
| 396 |
+
|
| 397 |
+
if grep -q jt6295 filtered.f; then
|
| 398 |
+
for i in $MODULES/jt6295/hdl/*.hex; do ln -srf $i; done
|
| 399 |
+
fi
|
| 400 |
+
|
| 401 |
+
# These tools use the same names for their executables, so the
|
| 402 |
+
# PATH is defined here
|
| 403 |
+
case $SIMULATOR in
|
| 404 |
+
questasim)
|
| 405 |
+
require "$QUESTASIM_LIC" "Define the right path for the QuestaSim license"
|
| 406 |
+
export LM_LICENSE_FILE="$QUESTASIM_LIC"
|
| 407 |
+
require "$QUESTASIM_PATH" "Define QUESTASIM_PATH to run ModelSim"
|
| 408 |
+
export PATH="$PATH:$QUESTASIM_PATH";;
|
| 409 |
+
modelsim)
|
| 410 |
+
require "$MODELSIM_PATH" "Define MODELSIM_PATH to run ModelSim"
|
| 411 |
+
export PATH="$PATH:$MODELSIM_PATH";;
|
| 412 |
+
esac
|
| 413 |
+
|
| 414 |
+
case $SIMULATOR in
|
| 415 |
+
iverilog)
|
| 416 |
+
SIMEXE=sim
|
| 417 |
+
$SHOWCMD iverilog -g2005-sv $SIMARGS \
|
| 418 |
+
$SIMULATOR_EXTRA \
|
| 419 |
+
-s $TOP -o $SIMEXE \
|
| 420 |
+
-DIVERILOG $EXTRA -I$CORES/$SYSNAME/hdl -I$JTFRAME/hdl/inc \
|
| 421 |
+
-I$MODULES/jtkcpu/hdl -I$MODULES/jt900h/hdl \
|
| 422 |
+
-DDUMP_VIDEO_FNAME=\"video.pipe\" $FILES \
|
| 423 |
+
|| exit 1
|
| 424 |
+
$SHOWCMD $SIMEXE -lxt
|
| 425 |
+
rm -f $SIMEXE;;
|
| 426 |
+
modelsim|questasim)
|
| 427 |
+
# vcom compiles VHDL, vlog compiles verilog
|
| 428 |
+
if [ -s jtsim_vhdl.f ]; then
|
| 429 |
+
$SHOWCMD vcom -f jtsim_vhdl.f || exit $?
|
| 430 |
+
fi
|
| 431 |
+
$SHOWCMD vlog -svfilesuffix=sv -svinputport=net -suppress vlog-7061 \
|
| 432 |
+
+initwireX $SIMULATOR_EXTRA \
|
| 433 |
+
+incdir+$CORES/$SYSNAME/hdl +incdir+$JTFRAME/hdl/inc \
|
| 434 |
+
+incdir+$MODULES/jtkcpu/hdl +incdir+$MODULES/jt900h/hdl \
|
| 435 |
+
$SIMARGS $SIMULATOR_EXTRA\
|
| 436 |
+
$EXTRA +define+DUMP_VIDEO_FNAME=\"video.pipe\" \
|
| 437 |
+
$FILES || exit $?
|
| 438 |
+
echo calling vsim $TOP
|
| 439 |
+
# The simulation script can be replaced locally
|
| 440 |
+
if [ ! -e vsim.do ]; then
|
| 441 |
+
cat >vsim.do <<EOF
|
| 442 |
+
run -all
|
| 443 |
+
EOF
|
| 444 |
+
fi
|
| 445 |
+
vsim -64 -batch -do "do vsim.do" $TOP || exit $?
|
| 446 |
+
if [ -e test.vcd ]; then vcd2fst test.vcd test.fst && rm test.vcd; fi
|
| 447 |
+
;;
|
| 448 |
+
xcelium)
|
| 449 |
+
$SHOWCMD xrun -64bit -access +r -timescale 1ns/1ps\
|
| 450 |
+
-f filtered.f $FILES -nowarn RECOME \
|
| 451 |
+
-top $TOP \
|
| 452 |
+
-incdir $CORES/$SYSNAME/hdl -incdir $JTFRAME/hdl/inc \
|
| 453 |
+
-incdir $MODULES/jtkcpu/hdl -incdir $MODULES/jt900h/hdl \
|
| 454 |
+
$SIMARGS $SIMULATOR_EXTRA\
|
| 455 |
+
-define DUMP_VIDEO_FNAME=\"video.pipe\" \
|
| 456 |
+
$EXTRA -l /dev/null || exit $?;;
|
| 457 |
+
synapticad)
|
| 458 |
+
# ls $JTFRAME/hdl/cpu/t80/T80{pa,_ALU,_Reg,_MCode,"",s}.vhd >> jtsim_vhdl.f
|
| 459 |
+
$SHOWCMD simx +access+r +define+SYNAPTICAD +timescale+1ns/1ps\
|
| 460 |
+
-f filtered.f $FILES \
|
| 461 |
+
+scd_top+$TOP \
|
| 462 |
+
+incdir+$CORES/$SYSNAME/hdl +incdir+$JTFRAME/hdl/inc \
|
| 463 |
+
+incdir+$MODULES/jtkcpu/hdl +incdir+$MODULES/jt900h/hdl \
|
| 464 |
+
$SIMARGS $SIMULATOR_EXTRA\
|
| 465 |
+
+define+DUMP_VIDEO_FNAME=\"video.pipe\" \
|
| 466 |
+
$EXTRA -l /dev/null || exit $?;;
|
| 467 |
+
ncverilog)
|
| 468 |
+
# ls $JTFRAME/hdl/cpu/t80/T80{pa,_ALU,_Reg,_MCode,"",s}.vhd >> jtsim_vhdl.f
|
| 469 |
+
$SHOWCMD ncverilog +access+r +nc64bit +define+NCVERILOG +nctimescale+1ns/1ps\
|
| 470 |
+
-mcmaxcores 3 -mccodegen \
|
| 471 |
+
-sysv -f jtsim_vhdl.f \
|
| 472 |
+
-disable_sem2009 $FILES \
|
| 473 |
+
+nctop+$TOP \
|
| 474 |
+
+incdir+$CORES/$SYSNAME/hdl +incdir+$JTFRAME/hdl/inc \
|
| 475 |
+
+incdir+$MODULES/jtkcpu/hdl +incdir+$MODULES/jt900h/hdl \
|
| 476 |
+
-ncvhdl_args,-V93 \
|
| 477 |
+
$SIMARGS $SIMULATOR_EXTRA\
|
| 478 |
+
+define+DUMP_VIDEO_FNAME=\"video.pipe\" \
|
| 479 |
+
-nowarn "MCONDE" -nowarn "NOCOND" -nowarn "RECOME" -nowarn "ZROMCW" \
|
| 480 |
+
$EXTRA -l /dev/null || exit $?;;
|
| 481 |
+
verilator)
|
| 482 |
+
TRACE=$(if [ ! -z "$DUMP" ]; then echo --trace; fi)
|
| 483 |
+
if [ -z "$CPPFLAGS" ]; then
|
| 484 |
+
if [[ ! -z "$MAXFRAME" && "$MAXFRAME" -gt 600 ]]; then
|
| 485 |
+
export CPPFLAGS="-O2 -march=native"
|
| 486 |
+
echo "Using CPPFLAGS=$CPPFLAGS for faster simulation"
|
| 487 |
+
else
|
| 488 |
+
export CPPFLAGS=-O1
|
| 489 |
+
fi
|
| 490 |
+
fi
|
| 491 |
+
if [ ! -z "$TRACE" ]; then
|
| 492 |
+
export CPPFLAGS="$CPPFLAGS -DVERILATOR_TRACE"
|
| 493 |
+
fi
|
| 494 |
+
if [ -z "$TESTCPP" ]; then
|
| 495 |
+
cp $JTFRAME/hdl/ver/test.cpp .
|
| 496 |
+
fi
|
| 497 |
+
# verilog to C++ conversion
|
| 498 |
+
GAME_VLT=
|
| 499 |
+
if [ -e game.vlt ]; then
|
| 500 |
+
GAME_VLT=game.vlt
|
| 501 |
+
fi
|
| 502 |
+
# Ignore FX68k in Verilator sims with this:
|
| 503 |
+
# but if you use JTFPGA/FX68K branch fix 6, you should be able to simulate it
|
| 504 |
+
if [ ! -z "$VERILATOR_ROOT" ]; then VERILATOR_PATH=${VERILATOR_ROOT}/bin/; fi
|
| 505 |
+
if [ ! -z "$COV" ]; then echo "#define _COVERAGE" >> defmacros.h; fi
|
| 506 |
+
rm -rf logs
|
| 507 |
+
VERILATOR_CMD=`make_verilator_command`
|
| 508 |
+
$SHOWCMD $VERILATOR_CMD --top-module game_test || exit $?
|
| 509 |
+
if is_lint_on; then
|
| 510 |
+
$VERILATOR_CMD --top-module jtframe_board
|
| 511 |
+
fi
|
| 512 |
+
# Only use parallel compilation if we are not in a regression. Otherwise
|
| 513 |
+
# all simulations will compete against each other for CPU resources
|
| 514 |
+
if [ -z "$JTFRAME_REGRESSION" ]; then MAKEJOBS=-j; fi
|
| 515 |
+
if echo "$EXTRA" | grep -q lint-only; then
|
| 516 |
+
echo "Lint only: no simulation "
|
| 517 |
+
else
|
| 518 |
+
compile_verilator_sim
|
| 519 |
+
# Run the simulation
|
| 520 |
+
prepare_fst_pipe
|
| 521 |
+
run_verilator_sim
|
| 522 |
+
clean_fst_pipe
|
| 523 |
+
if [ -e logs/coverage.dat ]; then
|
| 524 |
+
run_coverage
|
| 525 |
+
fi
|
| 526 |
+
if [ ! -z "$SHOWCMD" ]; then exit 0; fi
|
| 527 |
+
fi
|
| 528 |
+
esac
|
| 529 |
+
|
| 530 |
+
clean_up
|
| 531 |
+
|
| 532 |
+
convert_raw2wav
|
| 533 |
+
check_shasum
|
| 534 |
+
if [ `count_frame_images` -gt 250 ]; then
|
| 535 |
+
make_mpeg
|
| 536 |
+
fi
|
| 537 |
+
|
| 538 |
+
# convert per-channel raw sound files to wav
|
| 539 |
+
convert_channel_raw2wav
|
| 540 |
+
|
| 541 |
+
# Show simulation time
|
| 542 |
+
END_TIME=$(date +%s)
|
| 543 |
+
COMPILE_TIME=$[$END_TIME - $START_TIME]
|
| 544 |
+
MINUTES=$[$COMPILE_TIME / 60]
|
| 545 |
+
SECONDS=$[$COMPILE_TIME % 60]
|
| 546 |
+
|
| 547 |
+
echo "====== JTSIM finished in "$MINUTES\'$SECONDS\"" ======"
|
| 548 |
+
|
| 549 |
+
if [[ ! -z "$SCENE" && -e frames/frame_00001.jpg ]]; then
|
| 550 |
+
if [ ! -z "$BATCH" ]; then
|
| 551 |
+
copy_scene_frame
|
| 552 |
+
elif which eom > /dev/null; then
|
| 553 |
+
display_scene_frame&
|
| 554 |
+
fi
|
| 555 |
+
fi
|
| 556 |
+
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtsim-funcs
ADDED
|
@@ -0,0 +1,525 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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|
+
JTFRAME simulation tool. (c) Jose Tejada 2019-2022, @topapate
|
| 4 |
+
Please support the development: https://patreon.com/jotego
|
| 5 |
+
|
| 6 |
+
-args Additional arguments for the simulator
|
| 7 |
+
-batch Tells jtsim that it is being run by a batch process
|
| 8 |
+
-cov Enables coverage simulation (only verilator)
|
| 9 |
+
Look at the files in the cov folder for annotated results
|
| 10 |
+
-d Add specific Verilog macros for the simulation.
|
| 11 |
+
Call jtmacros to display all macros.
|
| 12 |
+
-debug_bus x
|
| 13 |
+
Sets the debug_bus value to x (sets JTFRAME_SIM_DEBUG)
|
| 14 |
+
-dir Create directory for the simulation. Use with -setname
|
| 15 |
+
-deep Save all signals for scope verification. See -w below.
|
| 16 |
+
-dipsw Set the DIP sw for simulation. Use with hexadecimal number
|
| 17 |
+
Default DIP switch values for each game are dumped in ASCII
|
| 18 |
+
to .dip files in $ROM.
|
| 19 |
+
If the simulation is run from a folder whose name matches a
|
| 20 |
+
.dip file in $ROM, and -dipsw is not set, then jtsim will load
|
| 21 |
+
the matching file automatically
|
| 22 |
+
-dump n Uses IOCTL interface to dump the core contents. Sets ioctl_ram,
|
| 23 |
+
requires JTFRAME_IOCTL_RD. Dumping will start at frame n
|
| 24 |
+
-fast Sets optimizer level to 3 when running Verilator sims. It may cause stability problems.
|
| 25 |
+
-frame Number of frames to simulate
|
| 26 |
+
-frate Define the frame rate. Used for generating .mp4 files. Adds JTFRAME_SIM_VIDEO to dump all frames.
|
| 27 |
+
-gates Gate-level simulation
|
| 28 |
+
-gfx xx Sets JTFRAME_SIM_GFXEN to the given hex value
|
| 29 |
+
-fx68k Keep FX68K files for Icarus Verilog
|
| 30 |
+
-inputs Defines SIM_INPUTS macro:
|
| 31 |
+
Game cabinet inputs will be taken from sim_inputs.hex or
|
| 32 |
+
from the file name after -inputs. Note that in if you specify
|
| 33 |
+
a file, then sim_inputs.hex will get overwritten with that file.
|
| 34 |
+
|
| 35 |
+
The input file can be in .cab format (see jtframe cab --help) or
|
| 36 |
+
in plain hex format.
|
| 37 |
+
|
| 38 |
+
In hex format each line contains a byte with the input status.
|
| 39 |
+
All bits are read as active high. They are inverted
|
| 40 |
+
if necessary by JTFRAME logic,
|
| 41 |
+
The format is:
|
| 42 |
+
bit | Meaning
|
| 43 |
+
3:0 | { start[1:0], service, coin[0] }
|
| 44 |
+
7:4 | joystick for 1P
|
| 45 |
+
| UP, DOWN, LEFT, RIGHT
|
| 46 |
+
10:8 | buttons
|
| 47 |
+
| B3, B2, B1
|
| 48 |
+
11 | test
|
| 49 |
+
-iverilog Use Icarus Verilog as the simulator
|
| 50 |
+
-lint Run verilator as lint tool
|
| 51 |
+
-load Load the ROM file using the SPI communication. Slower.
|
| 52 |
+
-modelsim Use ModelSim as the simulator
|
| 53 |
+
-modules Location of the modules folder with respect to the simulation folder
|
| 54 |
+
-mist Use MiST setup for simulation, instead of using directly the
|
| 55 |
+
game module. This is slower but more informative.
|
| 56 |
+
-ncverilog Select NCVerilog as the simulator
|
| 57 |
+
-nosnd|-q Disable SOUND hardware. Speeds up simulation a lot!
|
| 58 |
+
-pause Enable pause DIP setting. Same as -d DIP_PAUSE
|
| 59 |
+
-pocket Select PocketFPGA as target platform
|
| 60 |
+
-questasim Use QuestaSim as the simulator
|
| 61 |
+
-s|-scene Simulates a scene dump. These dumps can be obtained through FPGA runs,
|
| 62 |
+
MAME emulation or simulation. New cores and encouraged to use the ioctl
|
| 63 |
+
dump features in mem.yaml to create these dumps.
|
| 64 |
+
-safe Disable verilator optimizations that may halt the elaboration stage
|
| 65 |
+
-setname Creates the .rom file for the given MAME setname by looking in the MRA folder
|
| 66 |
+
-shaup Update the .sha file with the shasum for each frame.jpg
|
| 67 |
+
-srate Sampling rate of the .wav file
|
| 68 |
+
-stats Run SDRAM usage analysis
|
| 69 |
+
-synap Use Synapticad's simulator
|
| 70 |
+
-time Number of milliseconds to simulate
|
| 71 |
+
-test Enable test DIP setting. Same as -d DIP_TEST
|
| 72 |
+
-keepcpp Do not overwrite the test.cpp file from the JTUTIL version
|
| 73 |
+
-skipROM Do not generate .rom files
|
| 74 |
+
-slowpll Simulate using Altera's model for PLLs
|
| 75 |
+
-showcmd Display the simulation command only. Do not run any simulation.
|
| 76 |
+
-u,-undef Undefine macro during simulation
|
| 77 |
+
-verilator Use Verilator as the simulator
|
| 78 |
+
-video Enable video output. Can be followed by a number to get
|
| 79 |
+
the number of frames to simulate.
|
| 80 |
+
-w [#] Save a small set of signals for scope verification. If a number
|
| 81 |
+
is written after -w, the dump will start at that frame
|
| 82 |
+
-zoom Enlarge output images
|
| 83 |
+
EOF
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
define_terminal_colors() {
|
| 87 |
+
if [ -n "$TERM" ]; then # if running on a terminal
|
| 88 |
+
export TERM
|
| 89 |
+
red=`tput setaf 1`
|
| 90 |
+
green=`tput setaf 2`
|
| 91 |
+
blue=`tput setaf 4`
|
| 92 |
+
white=`tput setaf 7`
|
| 93 |
+
rBG=`tput setab 1; tput setaf 7`
|
| 94 |
+
gBG=`tput setab 2; tput setaf 7`
|
| 95 |
+
bBG=`tput setab 4; tput setaf 7`
|
| 96 |
+
yBG=`tput setab 3; tput setaf 7`
|
| 97 |
+
wBG=`tput setab 7; tput setaf 0`
|
| 98 |
+
NC=`tput sgr0`
|
| 99 |
+
fi
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
has_parent() {
|
| 103 |
+
p=`pwd`
|
| 104 |
+
while [ "$p" != "/" ]; do
|
| 105 |
+
parent=$(dirname "$p")
|
| 106 |
+
if [ $(basename "$parent") = "$1" ]; then return 0; fi
|
| 107 |
+
p=$parent
|
| 108 |
+
done
|
| 109 |
+
return 1
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
clean_up() {
|
| 113 |
+
rm -f video.pipe frame.raw \
|
| 114 |
+
game.f jtsim.f jtsim_vhdl.f simfile.f *bak *.def \
|
| 115 |
+
make.log defmacros.h filtered.f microrom.mem nanorom.mem
|
| 116 |
+
if [ -z "$TESTCPP" ]; then rm -f test.cpp; fi
|
| 117 |
+
rm -f video.raw video.pipe
|
| 118 |
+
echo -e "\e[0m"
|
| 119 |
+
echo
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
add_dir() {
|
| 123 |
+
if [ ! -d "$1" ]; then
|
| 124 |
+
echo "${rBG}Error:${NC} add_dir (sim.sh) failed because $1 is not a directory" 1>&2
|
| 125 |
+
exit 1
|
| 126 |
+
fi
|
| 127 |
+
processF=no
|
| 128 |
+
echo "Adding dir $1 $2" >&2
|
| 129 |
+
for i in $(cat $1/$2); do
|
| 130 |
+
if [ "$i" = "-sv" ]; then
|
| 131 |
+
# ignore statements that iVerilog cannot understand
|
| 132 |
+
continue;
|
| 133 |
+
fi
|
| 134 |
+
if [ "$processF" = yes ]; then
|
| 135 |
+
processF=no
|
| 136 |
+
# echo $(dirname $i) >&2
|
| 137 |
+
# echo $(basename $i) >&2
|
| 138 |
+
dn=$(dirname $i)
|
| 139 |
+
if [ "$dn" = . ]; then
|
| 140 |
+
dn=$1
|
| 141 |
+
fi
|
| 142 |
+
add_dir $dn $(basename $i)
|
| 143 |
+
continue
|
| 144 |
+
fi
|
| 145 |
+
if [[ "$i" = -F || "$i" == -f ]]; then
|
| 146 |
+
processF=yes
|
| 147 |
+
continue
|
| 148 |
+
fi
|
| 149 |
+
# ignore comments
|
| 150 |
+
if [ "${i:0:1}" = \# ]; then
|
| 151 |
+
continue
|
| 152 |
+
fi
|
| 153 |
+
fn="$1/$i"
|
| 154 |
+
if [ ! -e "$fn" ]; then
|
| 155 |
+
(>&2 echo "Cannot find file $fn")
|
| 156 |
+
fi
|
| 157 |
+
echo $fn
|
| 158 |
+
done
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
# iverilog does not have a -F command:
|
| 162 |
+
emulate_F() {
|
| 163 |
+
oldIFS="$IFS"
|
| 164 |
+
while IFS= read -r line; do
|
| 165 |
+
if [ `expr "$line" : -F ` -eq 2 ]; then
|
| 166 |
+
line=${line:3}
|
| 167 |
+
dname=$(dirname "$line")
|
| 168 |
+
fname=$(basename "$line")
|
| 169 |
+
add_dir $dname $fname
|
| 170 |
+
else
|
| 171 |
+
echo "$line"
|
| 172 |
+
fi
|
| 173 |
+
done < $1
|
| 174 |
+
IFS="$oldIFS"
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
# First parse all the arguments in search of simulator arguments
|
| 178 |
+
preparse_args() {
|
| 179 |
+
while [ $# -gt 0 ]; do
|
| 180 |
+
case ${1:1} in
|
| 181 |
+
verilator|lint)
|
| 182 |
+
SIMULATOR=verilator
|
| 183 |
+
MACROPREFIX=-D
|
| 184 |
+
;;
|
| 185 |
+
ncverilog|synapticad|modelsim|iverilog|questasim)
|
| 186 |
+
SIMULATOR=${1:1}
|
| 187 |
+
MACROPREFIX=+define+
|
| 188 |
+
;;
|
| 189 |
+
xcelium)
|
| 190 |
+
SIMULATOR=${1:1}
|
| 191 |
+
MACROPREFIX="-define "
|
| 192 |
+
;;
|
| 193 |
+
sysname) shift; SYSNAME=$1
|
| 194 |
+
esac
|
| 195 |
+
shift
|
| 196 |
+
done
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
require() {
|
| 200 |
+
if [ -z "$1" ]; then
|
| 201 |
+
echo "${rBG}Error:${NC} $2"
|
| 202 |
+
exit 1
|
| 203 |
+
fi
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
enable_load() {
|
| 207 |
+
# Moves away the old files to prevent mistakes
|
| 208 |
+
if [[ -e sdram_bank0.bin || -e sdram_bank0.hex ]]; then
|
| 209 |
+
echo "Moving old sdram_bank files to sdram.old"
|
| 210 |
+
mkdir -p sdram.old
|
| 211 |
+
mv sdram_bank?.* sdram.old > /dev/null
|
| 212 |
+
fi
|
| 213 |
+
add_macro LOADROM
|
| 214 |
+
echo ROM load through SPI enabled
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
add_macro() {
|
| 218 |
+
if [ $# = 0 ]; then return; fi
|
| 219 |
+
if [ ! -z "$ALLMACROS" ]; then
|
| 220 |
+
ALLMACROS=${ALLMACROS},
|
| 221 |
+
fi
|
| 222 |
+
ALLMACROS=${ALLMACROS}$1
|
| 223 |
+
shift
|
| 224 |
+
add_macro $*
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
has_macro() {
|
| 228 |
+
local name="$1"
|
| 229 |
+
test ! -z "`get_macro $1`"
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
get_macro() {
|
| 233 |
+
local name="$1"
|
| 234 |
+
if [ -z "$name" ]; then return; fi
|
| 235 |
+
IFS=',' read -ra allmacros <<< "$ALLMACROS"
|
| 236 |
+
for macro in "${allmacros[@]}"; do
|
| 237 |
+
local macro_name macro_value
|
| 238 |
+
macro_name="${macro%%=*}"
|
| 239 |
+
if [[ "$macro" == *"="* ]]; then
|
| 240 |
+
macro_value="${macro#*=}"
|
| 241 |
+
fi
|
| 242 |
+
if [ $macro_name = $name ]; then
|
| 243 |
+
echo $macro_value
|
| 244 |
+
return
|
| 245 |
+
fi
|
| 246 |
+
done
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
warn_if_longsim_noinputs() {
|
| 250 |
+
local maxframes
|
| 251 |
+
maxframes=`get_macro MAXFRAME`
|
| 252 |
+
if [ -z "$maxframes" ]; then return; fi
|
| 253 |
+
if [ "$maxframes" -lt 100 ]; then return; fi
|
| 254 |
+
if ! has_macro SIM_INPUTS; then
|
| 255 |
+
echo "${rBG}WARNING:${NC} Long simulation ($maxframes frames) without cabinet inputs"
|
| 256 |
+
fi
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
set_mist_as_target() {
|
| 260 |
+
TOP=mist_test
|
| 261 |
+
TARGET=mist
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
set_sidi128_as_target() {
|
| 265 |
+
TOP=mist_test
|
| 266 |
+
TARGET=sidi128
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
set_zoom() {
|
| 270 |
+
export CONVERT_OPTIONS="-filter point -resize 200% $CONVERT_OPTIONS"
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
# Use this function to create
|
| 274 |
+
# HEX files with initial contents for some of the RAMs
|
| 275 |
+
clear_hex_file() {
|
| 276 |
+
cnt=0
|
| 277 |
+
rm -f $1.hex
|
| 278 |
+
while [ $cnt -lt $2 ]; do
|
| 279 |
+
echo 0 >> $1.hex
|
| 280 |
+
cnt=$((cnt+1))
|
| 281 |
+
done
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
jtcfgstr() {
|
| 285 |
+
jtframe cfgstr $SYSNAME --target=$TARGET --output=$1 --def=$ALLMACROS --undef=$UNDEF
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
make_verilator_command() {
|
| 289 |
+
echo "${VERILATOR_PATH}verilator -I$CORES/$SYSNAME/hdl"\
|
| 290 |
+
" -I$JTFRAME/hdl/inc "\
|
| 291 |
+
" -I$MODULES/jtkcpu/hdl -I$MODULES/jt900h/hdl "\
|
| 292 |
+
" --timescale 1ps/1ps "\
|
| 293 |
+
" $JTFRAME/hdl/ver/game_test.v $JTFRAME/hdl/video/jtframe_lfbuf*.v $JTFRAME/hdl/ver/psram128.v $SIMARGS "\
|
| 294 |
+
" -Wno-TIMESCALEMOD --timescale-override 1ns/1ps -Wno-fatal "\
|
| 295 |
+
" -o sim "\
|
| 296 |
+
" $EXTRA $TRACE --prefix UUT --assert "\
|
| 297 |
+
" --cc test.cpp --exe $SIMULATOR_EXTRA $COV "\
|
| 298 |
+
" -Wwarn-UNDRIVEN --waiver-output waiver $GAME_VLT $VERILATOR_SAFE "
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
is_lint_on() {
|
| 302 |
+
echo "$EXTRA" | grep lint-only
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
compile_verilator_sim() {
|
| 306 |
+
# boost C++ optimization without affecting other settings
|
| 307 |
+
if [ ! -z "$FAST" ]; then export CPPFLAGS=`echo "$CPPFLAGS" | sed s/-O1/-O3/`; fi
|
| 308 |
+
if ! make $MAKEJOBS -C obj_dir -f UUT.mk sim > make.log; then
|
| 309 |
+
cat make.log
|
| 310 |
+
exit $?
|
| 311 |
+
fi
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
prepare_fst_pipe() {
|
| 315 |
+
rm -f test.vcd
|
| 316 |
+
if [[ -n "$DUMP" && -z "$SHOWCMD" ]]; then
|
| 317 |
+
if which vcd2fst > /dev/null; then
|
| 318 |
+
mkfifo test.vcd
|
| 319 |
+
vcd2fst -p test.vcd test.fst&
|
| 320 |
+
fi
|
| 321 |
+
fi
|
| 322 |
+
}
|
| 323 |
+
|
| 324 |
+
run_verilator_sim() {
|
| 325 |
+
$SHOWCMD obj_dir/sim $TRACE -time $SIM_MS || echo "Verilator sim exit code $?"
|
| 326 |
+
}
|
| 327 |
+
|
| 328 |
+
clean_fst_pipe() {
|
| 329 |
+
rm -f test.vcd
|
| 330 |
+
}
|
| 331 |
+
|
| 332 |
+
run_coverage() {
|
| 333 |
+
mkdir -p cov
|
| 334 |
+
verilator_coverage --annotate cov logs/coverage.dat
|
| 335 |
+
}
|
| 336 |
+
|
| 337 |
+
convert_raw2wav() {
|
| 338 |
+
if [ -e sound.raw ]; then
|
| 339 |
+
$JTUTIL/bin/raw2wav $SAMPLING_RATE < sound.raw
|
| 340 |
+
rm -f sound.raw
|
| 341 |
+
fi
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
check_shasum() {
|
| 345 |
+
if [ ! -z "$SETNAME" ]; then
|
| 346 |
+
if [ ! -z "$SHAUP" ]; then
|
| 347 |
+
shasum frame*jpg > ../$SETNAME.sha;
|
| 348 |
+
elif [ -e ../$SETNAME.sha ]; then
|
| 349 |
+
if shasum --check ../$SETNAME.sha; then echo PASS; else echo FAIL; fi
|
| 350 |
+
fi
|
| 351 |
+
fi
|
| 352 |
+
}
|
| 353 |
+
|
| 354 |
+
count_frame_images() {
|
| 355 |
+
ls frames/frame*jpg 2>/dev/null | wc -l
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
+
make_mpeg() {
|
| 359 |
+
if [ -z "$FRAMERATE" ]; then
|
| 360 |
+
FRAMERATE=30
|
| 361 |
+
echo "Define and export FRAMERATE"
|
| 362 |
+
if has_macro JTFRAME_SIM_VIDEO; then
|
| 363 |
+
FRAMERATE=60;
|
| 364 |
+
elif [ $(ls frames/frame*jpg 2>/dev/null | wc -l ) -gt 2000 ]; then
|
| 365 |
+
echo "Large number of frames... maybe enable JTFRAME_SIM_VIDEO to create a full video"
|
| 366 |
+
fi
|
| 367 |
+
fi
|
| 368 |
+
if [[ "$VIDEO_DUMP" = TRUE ]]; then
|
| 369 |
+
ffmpeg -y -framerate $FRAMERATE \
|
| 370 |
+
-pattern_type glob -i frames/'frame_*.jpg' \
|
| 371 |
+
-i test.wav -c:a aac -c:v libx264 -vf "scale=iw*3:ih*3" \
|
| 372 |
+
-pix_fmt yuv420p test.mp4 > /dev/null 2>&1
|
| 373 |
+
fi
|
| 374 |
+
}
|
| 375 |
+
|
| 376 |
+
convert_channel_raw2wav() {
|
| 377 |
+
shopt -s nullglob
|
| 378 |
+
CHRAW=(ch?.raw)
|
| 379 |
+
shopt -u nullglob
|
| 380 |
+
for i in "${CHRAW[@]}"; do
|
| 381 |
+
if [ $(od -An -tx1 -v $i | grep -v ' 00 ' | wc -l) -eq 0 ]; then
|
| 382 |
+
echo "$i is empty, deleting it" > /dev/null
|
| 383 |
+
else
|
| 384 |
+
ffmpeg -y -f s16le -ar 192000 -ac 2 -i $i ${i%.raw}.wav > /dev/null 2>&1 || continue
|
| 385 |
+
fi
|
| 386 |
+
rm -f $i
|
| 387 |
+
done
|
| 388 |
+
}
|
| 389 |
+
|
| 390 |
+
copy_scene_frame() {
|
| 391 |
+
SCNNUM=$(basename $(dirname $SCENE))
|
| 392 |
+
set -v
|
| 393 |
+
mv `ls frames/frame_*.jpg | tail -n 1` `dirname $SCENE`/$SCNNUM.jpg
|
| 394 |
+
set +v
|
| 395 |
+
}
|
| 396 |
+
|
| 397 |
+
display_scene_frame() {
|
| 398 |
+
last_frame_image=`ls frames/frame_*.jpg | tail -n 1`
|
| 399 |
+
eom $last_frame_image
|
| 400 |
+
}
|
| 401 |
+
|
| 402 |
+
use_setname() {
|
| 403 |
+
if [ ! -z "$DIR" ]; then # Run the simulation inside a folder named after the set
|
| 404 |
+
mkdir -p "$SETNAME" || exit $?
|
| 405 |
+
cd "$SETNAME"
|
| 406 |
+
fi
|
| 407 |
+
if [ -z "$SKIPROM" ]; then getset.sh $SYSNAME $SETNAME $SKIPROM || exit $?; fi
|
| 408 |
+
if [ -s $ROM/$SETNAME.dip ]; then
|
| 409 |
+
if ! has_macro JTFRAME_SIM_DIPS; then
|
| 410 |
+
# Not all systems have DIPs
|
| 411 |
+
DIPS=`cat $ROM/$SETNAME.dip`
|
| 412 |
+
if [ ! -z "$DIPS" ]; then add_macro JTFRAME_SIM_DIPS=0x$DIPS; fi
|
| 413 |
+
fi
|
| 414 |
+
fi
|
| 415 |
+
ROMFILE=$ROM/$SETNAME.rom
|
| 416 |
+
if [ ! -e $ROMFILE ]; then
|
| 417 |
+
cat<<EOF
|
| 418 |
+
jtsim: cannot produce $ROMFILE"
|
| 419 |
+
This may occur if the setname is longer than 8 characters or
|
| 420 |
+
if you are not in the core folder for the game
|
| 421 |
+
EOF
|
| 422 |
+
exit 1
|
| 423 |
+
fi
|
| 424 |
+
if [[ ! -e rom.bin || `readlink rom.bin` != "$ROMFILE" ]]; then
|
| 425 |
+
ln -srf $ROMFILE rom.bin
|
| 426 |
+
enable_load
|
| 427 |
+
fi
|
| 428 |
+
if [ -e $ROM/$SETNAME.mod ]; then cp $ROM/$SETNAME.mod core.mod; fi
|
| 429 |
+
}
|
| 430 |
+
|
| 431 |
+
derive_corename_from_folder() {
|
| 432 |
+
local corename=$(realpath `pwd` --relative-to=$CORES | cut -d/ -f1)
|
| 433 |
+
if [[ $corename == ..* ]]; then
|
| 434 |
+
echo "You must run jtsim from inside a folder in $CORES" >&2
|
| 435 |
+
exit 1
|
| 436 |
+
fi
|
| 437 |
+
echo $corename
|
| 438 |
+
}
|
| 439 |
+
|
| 440 |
+
derive_setname_from_folder() {
|
| 441 |
+
local setname=$(basename `pwd`)
|
| 442 |
+
echo $setname
|
| 443 |
+
}
|
| 444 |
+
|
| 445 |
+
get_default_dipsw() {
|
| 446 |
+
local setname="$1"
|
| 447 |
+
if [ -z "$setname" ]; then
|
| 448 |
+
echo "get_default_dipsw called by setname is blank"
|
| 449 |
+
exit 1
|
| 450 |
+
fi
|
| 451 |
+
local dipfile=$ROM/${setname}.dip
|
| 452 |
+
if [ ! -s $dipfile ]; then
|
| 453 |
+
echo "${rBG}WARNING${NC}: $ROM/${setname}.dip not found"
|
| 454 |
+
return
|
| 455 |
+
fi
|
| 456 |
+
local hexdip
|
| 457 |
+
hexdip=`cat $ROM/${setname}.dip`
|
| 458 |
+
add_macro JTFRAME_SIM_DIPS=0x$hexdip
|
| 459 |
+
echo "Using DIP switches from rom/${setname}.dip"
|
| 460 |
+
}
|
| 461 |
+
|
| 462 |
+
copy_mod_file() {
|
| 463 |
+
local setname="$1"
|
| 464 |
+
if [ ! -e $ROM/${setname}.mod ]; then
|
| 465 |
+
return
|
| 466 |
+
fi
|
| 467 |
+
cp $ROM/${setname}.mod core.mod
|
| 468 |
+
}
|
| 469 |
+
|
| 470 |
+
make_rombin_link() {
|
| 471 |
+
local setname="$1"
|
| 472 |
+
if [ -z "$setname" ]; then
|
| 473 |
+
echo "Create rom.bin manually or run the sim from a folder named after the ROM set name"
|
| 474 |
+
exit 1
|
| 475 |
+
fi
|
| 476 |
+
local romfile="$ROM/$setname.rom"
|
| 477 |
+
if [ ! -e $romfile ]; then
|
| 478 |
+
echo "ERROR: cannot make rom.bin from $romfile"
|
| 479 |
+
exit 1
|
| 480 |
+
fi
|
| 481 |
+
ln -sr $romfile rom.bin
|
| 482 |
+
}
|
| 483 |
+
|
| 484 |
+
get_file_length() {
|
| 485 |
+
local filename="$1"
|
| 486 |
+
if ! stat --version > /dev/null; then
|
| 487 |
+
stat -L -f %z $filename
|
| 488 |
+
else
|
| 489 |
+
stat -L -c%s $filename
|
| 490 |
+
fi
|
| 491 |
+
}
|
| 492 |
+
|
| 493 |
+
disable_patreon_credits() {
|
| 494 |
+
$SED /JTFRAME_CREDITS/d core.def
|
| 495 |
+
}
|
| 496 |
+
|
| 497 |
+
prepare_gatelevel_sim() {
|
| 498 |
+
# Gate-level simulation uses the synthesis output directly
|
| 499 |
+
GATENETLIST=$CORES/$SYSNAME/mist/simulation/ncsim/${CORENAME,,}_8_1200mv_85c_slow.vo
|
| 500 |
+
if [ ! -e "$GATENETLIST" ]; then
|
| 501 |
+
echo "${rBG}Error:${NC} cannot open the gate-level netlist. Looking for file"
|
| 502 |
+
echo "$GATENETLIST"
|
| 503 |
+
echo "Generate it using Quartus II, for the MiST core files"
|
| 504 |
+
exit 1
|
| 505 |
+
fi
|
| 506 |
+
QPATH=`which quartus`
|
| 507 |
+
if [[ -z "$QPATH" ]]; then
|
| 508 |
+
echo "${rBG}Error:${NC} Quartus is not in the PATH"
|
| 509 |
+
exit 1
|
| 510 |
+
fi
|
| 511 |
+
QPATH=${QPATH%quartus/bin/quartus}/modelsim_ae/altera/verilog/src
|
| 512 |
+
if [ ! -d "$QPATH" ]; then
|
| 513 |
+
echo "${rBG}Error:${NC} cannot find the path to Quartus simulation files"
|
| 514 |
+
echo Looking at "$QPATH"
|
| 515 |
+
exit 1
|
| 516 |
+
fi
|
| 517 |
+
echo $GATENETLIST > filtered.f
|
| 518 |
+
echo $QPATH/{altera_primitives,cycloneiii_atoms}.v >> filtered.f
|
| 519 |
+
echo $JTFRAME/target/mist/mist_test.v \
|
| 520 |
+
mist_dump.v \
|
| 521 |
+
+define+GATES \
|
| 522 |
+
>> filtered.f
|
| 523 |
+
# Remove MiST definitions
|
| 524 |
+
FILES=
|
| 525 |
+
}
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtsim-funcs-test.sh
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
source $JTFRAME/bin/jtsim-funcs
|
| 4 |
+
|
| 5 |
+
main() {
|
| 6 |
+
test_get_macro
|
| 7 |
+
test_has_macro
|
| 8 |
+
if [ "$FAIL" = 1 ]; then
|
| 9 |
+
exit 1
|
| 10 |
+
fi
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
fail() {
|
| 14 |
+
local msg="$*"
|
| 15 |
+
local test_name=${FUNCNAME[1]}
|
| 16 |
+
printf "%-20s FAIL %s\n" $test_name "$msg"
|
| 17 |
+
FAIL=1
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
pass() {
|
| 21 |
+
local bad="$1"
|
| 22 |
+
if [ ! -z "$bad" ]; then
|
| 23 |
+
return
|
| 24 |
+
fi
|
| 25 |
+
local test_name=${FUNCNAME[1]}
|
| 26 |
+
printf "%-20s PASS\n" $test_name
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
test_has_macro() {
|
| 30 |
+
local bad
|
| 31 |
+
ALLMACROS="a,d=,b=3,MAXFRAME=23,c=4"
|
| 32 |
+
if has_macro not_there; then
|
| 33 |
+
fail "found non existing macro"
|
| 34 |
+
bad=1
|
| 35 |
+
fi
|
| 36 |
+
if ! has_macro MAXFRAME; then
|
| 37 |
+
fail "coult not find MAXFRAME"
|
| 38 |
+
bad=1
|
| 39 |
+
fi
|
| 40 |
+
pass $bad
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
test_get_macro() {
|
| 45 |
+
ALLMACROS="a,d=,b=3,MAXFRAME=23,c=4"
|
| 46 |
+
local bad
|
| 47 |
+
|
| 48 |
+
if [ ! -z `get_macro` ]; then
|
| 49 |
+
fail empty case. Got -`get_macro`-
|
| 50 |
+
bad=1
|
| 51 |
+
fi
|
| 52 |
+
|
| 53 |
+
if [ ! -z `get_macro a` ]; then
|
| 54 |
+
fail a. Got `get_macro a`
|
| 55 |
+
bad=1
|
| 56 |
+
fi
|
| 57 |
+
|
| 58 |
+
if [ ! -z `get_macro d` ]; then
|
| 59 |
+
fail d
|
| 60 |
+
bad=1
|
| 61 |
+
fi
|
| 62 |
+
|
| 63 |
+
if [ "`get_macro b`" != 3 ]; then
|
| 64 |
+
fail "b expected 3 got" `get_macro b`
|
| 65 |
+
bad=1
|
| 66 |
+
fi
|
| 67 |
+
|
| 68 |
+
if [ "`get_macro MAXFRAME`" != 23 ]; then
|
| 69 |
+
fail "MAXFRAME expected 23 got" `get_macro MAXFRAME`
|
| 70 |
+
bad=1
|
| 71 |
+
fi
|
| 72 |
+
|
| 73 |
+
ALLMACROS="JTFRAME_SIM_DIPS=0xf0"
|
| 74 |
+
if [ -z "`get_macro JTFRAME_SIM_DIPS`" ]; then
|
| 75 |
+
fail "Cannot find JTFRAME_SIM_DIPS"
|
| 76 |
+
bad=1
|
| 77 |
+
fi
|
| 78 |
+
pass $bad
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
main $*
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtupdate
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# This file is part of JTFRAME.
|
| 3 |
+
# JTFRAME program is free software: you can redistribute it and/or modify
|
| 4 |
+
# it under the terms of the GNU General Public License as published by
|
| 5 |
+
# the Free Software Foundation, either version 3 of the License, or
|
| 6 |
+
# (at your option) any later version.
|
| 7 |
+
|
| 8 |
+
# JTFRAME program is distributed in the hope that it will be useful,
|
| 9 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 10 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 11 |
+
# GNU General Public License for more details.
|
| 12 |
+
|
| 13 |
+
# You should have received a copy of the GNU General Public License
|
| 14 |
+
# along with JTFRAME. If not, see <http://www.gnu.org/licenses/>.
|
| 15 |
+
|
| 16 |
+
# Author: Jose Tejada Gomez. Twitter: @topapate
|
| 17 |
+
# Version: 1.0
|
| 18 |
+
# Date: 12-1-2023
|
| 19 |
+
|
| 20 |
+
MAX_JOBS=
|
| 21 |
+
DRYRUN=
|
| 22 |
+
NETWORK=
|
| 23 |
+
GIT=
|
| 24 |
+
KEEP=
|
| 25 |
+
CORESTAMP=$(date +"%Y%m%d")
|
| 26 |
+
|
| 27 |
+
function parse_args {
|
| 28 |
+
while [ $# -gt 0 ]; do
|
| 29 |
+
case "$1" in
|
| 30 |
+
--jobs)
|
| 31 |
+
shift
|
| 32 |
+
MAX_JOBS="--jobs $1"
|
| 33 |
+
;;
|
| 34 |
+
--corestamp)
|
| 35 |
+
shift
|
| 36 |
+
CORESTAMP=$1
|
| 37 |
+
;;
|
| 38 |
+
--dry)
|
| 39 |
+
DRYRUN=--dry-run
|
| 40 |
+
KEEP=keep
|
| 41 |
+
;;
|
| 42 |
+
--keep)
|
| 43 |
+
KEEP=keep
|
| 44 |
+
;;
|
| 45 |
+
--git)
|
| 46 |
+
GIT=1
|
| 47 |
+
;;
|
| 48 |
+
--network)
|
| 49 |
+
NETWORK="--sshloginfile .."
|
| 50 |
+
;;
|
| 51 |
+
-h|--help)
|
| 52 |
+
jtframe update --help
|
| 53 |
+
exit 0;;
|
| 54 |
+
esac
|
| 55 |
+
shift
|
| 56 |
+
done
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
parse_args $* || exit $?
|
| 60 |
+
|
| 61 |
+
if [ -z "$GIT" ]; then
|
| 62 |
+
# Output to the release folder
|
| 63 |
+
export JTBIN=$JTROOT/release
|
| 64 |
+
if [ -z "$KEEP" ]; then
|
| 65 |
+
rm -rf $JTROOT/release.bak
|
| 66 |
+
if [ -d $JTROOT/release ]; then
|
| 67 |
+
mv $JTROOT/release $JTROOT/release.bak
|
| 68 |
+
fi
|
| 69 |
+
rm -rf $JTBIN
|
| 70 |
+
fi
|
| 71 |
+
mkdir -p $JTBIN
|
| 72 |
+
else
|
| 73 |
+
# Output to JTBIN
|
| 74 |
+
cd $JTBIN
|
| 75 |
+
if git status --short | grep -i "^ M " > /dev/null; then
|
| 76 |
+
echo "JTBIN has uncommited changes. Do you want to continue [y/n]?"
|
| 77 |
+
read CONT
|
| 78 |
+
if [ $CONT != y ]; then
|
| 79 |
+
exit 1
|
| 80 |
+
fi
|
| 81 |
+
fi
|
| 82 |
+
if [ `git branch --show-current` = master ]; then
|
| 83 |
+
git checkout -b `basename $JTROOT`_$CORESTAMP || exit $?
|
| 84 |
+
fi
|
| 85 |
+
fi
|
| 86 |
+
if [ -z "$KEEP" ]; then rm -rf $ROM; mkdir $ROM; fi
|
| 87 |
+
|
| 88 |
+
# TASKS is a temporary file with the list of tasks
|
| 89 |
+
TASKS=`mktemp`
|
| 90 |
+
|
| 91 |
+
jtframe update $* >> $TASKS || exit 1
|
| 92 |
+
|
| 93 |
+
if [ $(cat $TASKS|wc -l) = 0 ]; then
|
| 94 |
+
echo no jobs
|
| 95 |
+
exit 1
|
| 96 |
+
fi
|
| 97 |
+
|
| 98 |
+
if [[ -z "$DRYRUN" && -z "$KEEP" ]]; then
|
| 99 |
+
rm -f $JTROOT/log/builds.log
|
| 100 |
+
fi
|
| 101 |
+
|
| 102 |
+
# transfer the environment variables to each parallel server
|
| 103 |
+
source `which env_parallel.bash`
|
| 104 |
+
|
| 105 |
+
mkdir -p $JTROOT/log
|
| 106 |
+
rm -rf $JTROOT/log/*
|
| 107 |
+
if [ ! -z "$NETWORK" ]; then
|
| 108 |
+
TEMP=`mktemp`
|
| 109 |
+
while read LINE; do
|
| 110 |
+
echo "./modules/jtframe/bin/jtnet.sh $JTBIN $LINE" >> $TEMP
|
| 111 |
+
done < $TASKS
|
| 112 |
+
rm -f $TASKS
|
| 113 |
+
TASKS=$TEMP
|
| 114 |
+
fi
|
| 115 |
+
|
| 116 |
+
cat $TASKS | parallel --no-run-if-empty --colsep " " --sshdelay 0.25 \
|
| 117 |
+
--load 80% --memfree 4G --shuf --workdir $JTROOT \
|
| 118 |
+
$DRYRUN $NETWORK $MAX_JOBS\
|
| 119 |
+
--delay 0.25 $CMD {} $EXTRA | tee $JTROOT/log/update.log
|
| 120 |
+
|
| 121 |
+
rm -f $TASKS
|
| 122 |
+
|
| 123 |
+
if [ ! -z "$GIT" ]; then
|
| 124 |
+
# update JTBIN's md5.md file
|
| 125 |
+
jtutil md5
|
| 126 |
+
fi
|
| 127 |
+
# copy files to SD card if present
|
| 128 |
+
jtbin2sd
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/jtutil
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
if [ -z "$JTFRAME" ]; then
|
| 3 |
+
echo "Missing JTFRAME environment variable definition"
|
| 4 |
+
exit 1
|
| 5 |
+
fi
|
| 6 |
+
|
| 7 |
+
RECOMPILE=FALSE
|
| 8 |
+
BIN=$JTFRAME/src/jtutil/jtutil
|
| 9 |
+
|
| 10 |
+
if [[ ! -e $BIN || $# = 0 ]]; then
|
| 11 |
+
RECOMPILE=TRUE
|
| 12 |
+
else
|
| 13 |
+
# Find out whether the jtutil file is older
|
| 14 |
+
# than the JTFRAME's commit
|
| 15 |
+
cd $JTFRAME > /dev/null
|
| 16 |
+
COMMIT_DATE=`date -d "$(git show -s --format=%ci)" +"%s"`
|
| 17 |
+
COMPILED_DATE=`stat -c %Y $BIN`
|
| 18 |
+
if [ $COMPILED_DATE -lt $COMMIT_DATE ]; then
|
| 19 |
+
RECOMPILE=TRUE
|
| 20 |
+
fi
|
| 21 |
+
cd - > /dev/null
|
| 22 |
+
fi
|
| 23 |
+
|
| 24 |
+
if [ $RECOMPILE = TRUE ]; then
|
| 25 |
+
cd $JTFRAME/src/jtutil > /dev/null
|
| 26 |
+
go build . || exit $?
|
| 27 |
+
cd - > /dev/null
|
| 28 |
+
fi
|
| 29 |
+
|
| 30 |
+
$BIN $*
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/lint-all.sh
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
if [ -z "$JTFRAME" ]; then
|
| 4 |
+
cd /jtcores
|
| 5 |
+
git config --global --add safe.directory /jtcores
|
| 6 |
+
source setprj.sh
|
| 7 |
+
fi
|
| 8 |
+
|
| 9 |
+
WARNLIST=
|
| 10 |
+
ERRLIST=
|
| 11 |
+
FAIL=
|
| 12 |
+
LOGFOLDER=$JTROOT/log/linter
|
| 13 |
+
cd $CORES
|
| 14 |
+
rm -rf $LOGFOLDER
|
| 15 |
+
mkdir -p $LOGFOLDER
|
| 16 |
+
|
| 17 |
+
for core in *; do
|
| 18 |
+
if [ ! -d $core ]; then continue; fi
|
| 19 |
+
LOG=$LOGFOLDER/lint-$core.log
|
| 20 |
+
if ! $JTFRAME/bin/lint-one.sh $core > $LOG 2>&1; then
|
| 21 |
+
if [ ! -z "$ERRLIST" ]; then ERRLIST="$ERRLIST "; fi
|
| 22 |
+
ERRLIST="${ERRLIST}$core"
|
| 23 |
+
fi
|
| 24 |
+
if [ -e $LOG ]; then
|
| 25 |
+
if grep %Warning- $LOG > /dev/null; then
|
| 26 |
+
if [ ! -z "$WARNLIST" ]; then WARNLIST="$WARNLIST "; fi
|
| 27 |
+
WARNLIST="${WARNLIST}$core"
|
| 28 |
+
fi
|
| 29 |
+
fi
|
| 30 |
+
done
|
| 31 |
+
|
| 32 |
+
# print out all log files that have problems
|
| 33 |
+
if [[ ! -z "$WARNLIST" || ! -z "$ERRLIST" ]]; then
|
| 34 |
+
for core in $WARNLIST $ERRLIST; do
|
| 35 |
+
printf "=========== %8s ===========\n" $core
|
| 36 |
+
ls -l $LOGFOLDER/lint-$core.log
|
| 37 |
+
cat $LOGFOLDER/lint-$core.log
|
| 38 |
+
done
|
| 39 |
+
fi
|
| 40 |
+
|
| 41 |
+
function make_table {
|
| 42 |
+
if which column > /dev/null; then
|
| 43 |
+
echo $* | tr ' ' '\n' | column
|
| 44 |
+
else
|
| 45 |
+
echo $*
|
| 46 |
+
fi
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
function count_cores {
|
| 50 |
+
echo $* | wc -w
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
if [ ! -z "$WARNLIST" ]; then
|
| 54 |
+
echo "Cores with linter warnings:"
|
| 55 |
+
make_table $WARNLIST
|
| 56 |
+
echo `count_cores $WARNLIST` warnings
|
| 57 |
+
FAIL=1
|
| 58 |
+
fi
|
| 59 |
+
|
| 60 |
+
if [ ! -z "$ERRLIST" ]; then
|
| 61 |
+
echo "Cores with linter errors:"
|
| 62 |
+
make_table $ERRLIST
|
| 63 |
+
echo `count_cores $ERRLIST` errors
|
| 64 |
+
FAIL=1
|
| 65 |
+
fi
|
| 66 |
+
|
| 67 |
+
if [ -z "$FAIL" ]; then
|
| 68 |
+
echo "lint-all: PASS"
|
| 69 |
+
else
|
| 70 |
+
echo "lint-all: FAIL"
|
| 71 |
+
exit 1
|
| 72 |
+
fi
|
| 73 |
+
|
| 74 |
+
rm -f lint*.log
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/lint-changed.sh
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
cd $JTROOT
|
| 4 |
+
CHECK=`git status --short | grep "M cores" | cut -d/ -f 2 | sort | uniq`
|
| 5 |
+
if [ -z "$CHECK" ]; then exit 0; fi
|
| 6 |
+
|
| 7 |
+
TMP=`mktemp`
|
| 8 |
+
echo $CHECK | xargs $JTFRAME/bin/lint-one.sh > $TMP 2>&1
|
| 9 |
+
|
| 10 |
+
BAD=0
|
| 11 |
+
if grep %Warning $TMP; then BAD=1; fi
|
| 12 |
+
if grep -i error $TMP; then BAD=1; fi
|
| 13 |
+
if [ $BAD = 1 ]; then
|
| 14 |
+
cat $TMP
|
| 15 |
+
rm -f $TMP
|
| 16 |
+
exit 1
|
| 17 |
+
fi
|
| 18 |
+
rm -f $TMP
|
| 19 |
+
exit 0
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/lint-one.sh
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# use lint-one.sh core -u JTFRAME_SKIP
|
| 3 |
+
# for cores in development phase
|
| 4 |
+
|
| 5 |
+
trap "clean_up; exit 1" INT KILL
|
| 6 |
+
|
| 7 |
+
main() {
|
| 8 |
+
CORE=$1
|
| 9 |
+
shift
|
| 10 |
+
parse_args $*
|
| 11 |
+
set_target
|
| 12 |
+
read_core_macros "$FRAME_ARGS"
|
| 13 |
+
|
| 14 |
+
if must_skip; then
|
| 15 |
+
echo "Skipping $CORE"
|
| 16 |
+
exit 0
|
| 17 |
+
fi
|
| 18 |
+
|
| 19 |
+
prepare_test_folder
|
| 20 |
+
cd $TEST_FOLDER
|
| 21 |
+
make_dummy_rom
|
| 22 |
+
|
| 23 |
+
run_linter "$SIM_ARGS"
|
| 24 |
+
check_msg
|
| 25 |
+
clean_up
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
parse_args() {
|
| 29 |
+
FRAME_ARGS=
|
| 30 |
+
SIM_ARGS=
|
| 31 |
+
while [ $# -gt 0 ]; do
|
| 32 |
+
case "$1" in
|
| 33 |
+
-d|--def) shift
|
| 34 |
+
add_to_both -d $1;;
|
| 35 |
+
-u|--undef) shift
|
| 36 |
+
add_to_both --undef $1;;
|
| 37 |
+
--nodbg)
|
| 38 |
+
add_to_jtframe $1
|
| 39 |
+
add_to_jtsim -d JTFRAME_RELEASE;;
|
| 40 |
+
-o|--output) shift;;
|
| 41 |
+
--tpl) shift
|
| 42 |
+
add_to_jtframe --tpl $1;;
|
| 43 |
+
-t|--target) shift
|
| 44 |
+
TARGET=$1;;
|
| 45 |
+
-mist|-mister|-pocket|-sidi128)
|
| 46 |
+
TARGET=${1#-};;
|
| 47 |
+
*)
|
| 48 |
+
add_to_jtsim $*;;
|
| 49 |
+
esac
|
| 50 |
+
shift
|
| 51 |
+
done
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
add_to_jtframe() {
|
| 55 |
+
FRAME_ARGS+=" $*"
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
add_to_jtsim() {
|
| 59 |
+
SIM_ARGS+=" $*"
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
add_to_both() {
|
| 63 |
+
add_to_jtframe $*
|
| 64 |
+
add_to_jtsim $*
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
set_target() {
|
| 68 |
+
if [ -z "$TARGET" ]; then
|
| 69 |
+
TARGET=mister
|
| 70 |
+
fi
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
read_core_macros() {
|
| 74 |
+
eval `jtframe cfgstr $CORE --output bash --target $TARGET $*`
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
must_skip() {
|
| 78 |
+
[[ ! -e $CORES/$CORE/cfg/macros.def || -e $CORES/$CORE/cfg/skip || -v JTFRAME_SKIP ]]
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
prepare_test_folder() {
|
| 82 |
+
cd $CORES/$CORE
|
| 83 |
+
TEST_FOLDER=ver/lint
|
| 84 |
+
rm -rf $TEST_FOLDER
|
| 85 |
+
mkdir -p $TEST_FOLDER
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
make_dummy_rom() {
|
| 89 |
+
if [ ! -e rom.bin ]; then
|
| 90 |
+
# dummy ROM
|
| 91 |
+
dd if=/dev/zero of=rom.bin count=1 2> /dev/null
|
| 92 |
+
DELROM=
|
| 93 |
+
fi
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
run_linter() {
|
| 97 |
+
jtsim -lint -$TARGET $*
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
check_msg() {
|
| 101 |
+
jtframe msg $CORE
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
clean_up() {
|
| 105 |
+
rm -rf $TEST_FOLDER
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
main $*
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/logo128.png
ADDED
|
Git LFS Details
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/setprj.sh
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Define JTROOT before sourcing this file
|
| 3 |
+
|
| 4 |
+
if (echo $PATH | grep modules/jtframe/bin -q); then
|
| 5 |
+
unalias jtcore
|
| 6 |
+
PATH=$(echo $PATH | sed 's/:[^:]*jtframe\/bin//g')
|
| 7 |
+
PATH=$(echo $PATH | sed 's/:\.//g')
|
| 8 |
+
unset JT12 JT51 CC MRA ROM CORES
|
| 9 |
+
fi
|
| 10 |
+
|
| 11 |
+
export JTROOT=$(pwd)
|
| 12 |
+
export JTFRAME=$JTROOT/modules/jtframe
|
| 13 |
+
# . path comes before JTFRAME/bin as setprj.sh
|
| 14 |
+
# can be in the working directory and in JTFRAME/bin
|
| 15 |
+
PATH=$PATH:.:$JTFRAME/bin
|
| 16 |
+
|
| 17 |
+
if [ ! -d "$JTBIN" ]; then
|
| 18 |
+
export JTBIN=$JTROOT/release
|
| 19 |
+
mkdir -p $JTBIN
|
| 20 |
+
fi
|
| 21 |
+
|
| 22 |
+
# derived variables
|
| 23 |
+
export CORES=$JTROOT/cores
|
| 24 |
+
RLS=$JTROOT/release
|
| 25 |
+
# Adds all core names to the auto-completion list of bash
|
| 26 |
+
ALLCORES=$(ls $CORES| tr '\n' ' ')
|
| 27 |
+
complete -W "$ALLCORES" jtcore
|
| 28 |
+
complete -W "$ALLCORES" swcore
|
| 29 |
+
unset ALLFOLDERS
|
| 30 |
+
|
| 31 |
+
export ROM=$JTROOT/rom
|
| 32 |
+
export RLS=$JTROOT/release
|
| 33 |
+
export MRA=$JTROOT/release/mra
|
| 34 |
+
export POCKET=$JTFRAME/target/pocket
|
| 35 |
+
DOC=$JTROOT/doc
|
| 36 |
+
MAME=$JTROOT/doc/mame
|
| 37 |
+
export MODULES=$JTROOT/modules
|
| 38 |
+
|
| 39 |
+
function cdjt {
|
| 40 |
+
cd $JTROOT
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
function cdrls {
|
| 44 |
+
cd $JTROOT/release
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
function lint {
|
| 48 |
+
local CORENAME=$1
|
| 49 |
+
if [ -z "$CORENAME" ]; then
|
| 50 |
+
# derive the default core name from the path
|
| 51 |
+
CORENAME=$(realpath . --relative-to=$CORES)
|
| 52 |
+
CORENAME=${CORENAME%%/*}
|
| 53 |
+
fi
|
| 54 |
+
if [ ! -d "$CORES/$CORENAME" ]; then
|
| 55 |
+
echo "Use a valid core name or run it from inside the core folder"
|
| 56 |
+
return 1
|
| 57 |
+
fi
|
| 58 |
+
lint-one.sh $CORENAME -u JTFRAME_SKIP
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
function cpscene {
|
| 62 |
+
local ramfile
|
| 63 |
+
local scene_name="$1"
|
| 64 |
+
ramfile=`find /media/$USER -name "*.RAM" | head -n 1`
|
| 65 |
+
if [ ! -e "$ramfile" ]; then
|
| 66 |
+
echo "Did not find any .RAM files"
|
| 67 |
+
return 1
|
| 68 |
+
fi
|
| 69 |
+
if [ -z "$scene_name" ]; then
|
| 70 |
+
echo "You must specify a name for the scene"
|
| 71 |
+
return 1
|
| 72 |
+
fi
|
| 73 |
+
local folder="scenes/$scene_name"
|
| 74 |
+
mkdir -p "$folder" || return 1
|
| 75 |
+
mv $ramfile "$folder"/dump.bin
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
function swcore {
|
| 79 |
+
if [ -z "$JTROOT" ]; then
|
| 80 |
+
echo Have you forgot to define JTROOT?
|
| 81 |
+
return
|
| 82 |
+
fi
|
| 83 |
+
if [ ! -z "$2" ]; then
|
| 84 |
+
cd $JTROOT/cores/$1/$2
|
| 85 |
+
return
|
| 86 |
+
fi
|
| 87 |
+
if [ -z "$1" ]; then
|
| 88 |
+
echo "Use swcore <corename>"
|
| 89 |
+
return 1
|
| 90 |
+
fi
|
| 91 |
+
if [ ! -d "$JTROOT/cores/$1" ]; then
|
| 92 |
+
echo "No folder for $1 core"
|
| 93 |
+
return 1
|
| 94 |
+
fi
|
| 95 |
+
# get the location relative to $CORES/corename
|
| 96 |
+
local cores=$(realpath $JTROOT/cores)
|
| 97 |
+
local cur=`pwd`
|
| 98 |
+
cur="${cur#$cores/}"
|
| 99 |
+
if [ "$cur" = `pwd` ]; then
|
| 100 |
+
# not in a core folder
|
| 101 |
+
cd $JTROOT/cores/$1/$2
|
| 102 |
+
return
|
| 103 |
+
fi
|
| 104 |
+
# extract the path after the current core
|
| 105 |
+
cur="${cur#*/}"
|
| 106 |
+
cd "$JTROOT/cores/$1"
|
| 107 |
+
|
| 108 |
+
# replicate as much as possible from the previous location
|
| 109 |
+
IFS=/ read -ra folders <<< $cur
|
| 110 |
+
for i in ${folders[@]};do
|
| 111 |
+
if [ -d $i ]; then
|
| 112 |
+
cd $i
|
| 113 |
+
else
|
| 114 |
+
break
|
| 115 |
+
fi
|
| 116 |
+
done
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
# change to a folder inside "$CORES/*/ver" folders
|
| 120 |
+
function cdgame {
|
| 121 |
+
local setname=$1
|
| 122 |
+
if [ -z "$JTROOT" ]; then
|
| 123 |
+
echo Have you forgot to define JTROOT?
|
| 124 |
+
return 1
|
| 125 |
+
fi
|
| 126 |
+
if [ -z "$setname" ]; then
|
| 127 |
+
echo "Use cdgame <MAME setname>"
|
| 128 |
+
return 1
|
| 129 |
+
fi
|
| 130 |
+
local path=$(find $JTROOT/cores -name "$1" -path "*/ver/$setname" -type d | head -n 1)
|
| 131 |
+
if [ -z "$path" ]; then echo "No $setname in verification folders"; return 1; fi
|
| 132 |
+
cd "$path"
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
if [ "$1" != "--quiet" ]; then
|
| 136 |
+
echo "Use swcore <corename> to switch to a different core once you are"
|
| 137 |
+
echo "inside the cores folder"
|
| 138 |
+
fi
|
| 139 |
+
|
| 140 |
+
# Git prompt
|
| 141 |
+
source $JTFRAME/bin/git-prompt.sh
|
| 142 |
+
export GIT_PS1_SHOWUPSTREAM=
|
| 143 |
+
export GIT_PS1_SHOWDIRTYSTATE=
|
| 144 |
+
export GIT_PS1_SHOWCOLORHINTS=
|
| 145 |
+
function __git_subdir {
|
| 146 |
+
PWD=$(pwd)
|
| 147 |
+
echo ${PWD##${JTROOT}/}
|
| 148 |
+
}
|
| 149 |
+
PS1='[$(__git_subdir)$(__git_ps1 " (%s)")]\$ '
|
| 150 |
+
|
| 151 |
+
# Displays all available macros
|
| 152 |
+
# The argument is used to filter the output
|
| 153 |
+
function jtmacros {
|
| 154 |
+
case "$1" in
|
| 155 |
+
--using|-u)
|
| 156 |
+
for i in `find $CORES -name "*.def" | xargs grep --files-with-matches "$2"`; do
|
| 157 |
+
i=`dirname $i`
|
| 158 |
+
i=${i##$CORES/}
|
| 159 |
+
i=${i%%/cfg}
|
| 160 |
+
len0=${#i}
|
| 161 |
+
i=${i%%/ver/game}
|
| 162 |
+
len1=${#i}
|
| 163 |
+
if [ $len0 = $len1 ]; then echo $i; fi
|
| 164 |
+
done;;
|
| 165 |
+
--help|-h)
|
| 166 |
+
cat<<EOF
|
| 167 |
+
jtmacros shows macro related information.
|
| 168 |
+
Usage:
|
| 169 |
+
--using|-u name shows all cores using a given macro
|
| 170 |
+
--help|-h shows this screen
|
| 171 |
+
name shows the description of macro "name"
|
| 172 |
+
no arguments shows the description of all macros
|
| 173 |
+
EOF
|
| 174 |
+
;;
|
| 175 |
+
*)
|
| 176 |
+
if [ ! -z "$1" ]; then
|
| 177 |
+
grep -i "$1" $JTFRAME/doc/macros.md
|
| 178 |
+
else
|
| 179 |
+
cat $JTFRAME/doc/macros.md
|
| 180 |
+
echo
|
| 181 |
+
fi;;
|
| 182 |
+
esac
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
# Cleans up the simulation folder
|
| 186 |
+
function cleansim {
|
| 187 |
+
rm -f *.wav *.f *.def *bak *.raw *.bin test.* game_test.v frame*jpg \
|
| 188 |
+
microrom.mem nanorom.mem *.log *.h waiver
|
| 189 |
+
rm -rf obj_dir sdram.old cfg history
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
# compare two binary files
|
| 193 |
+
function hexdiff {
|
| 194 |
+
sdiff --suppress-common-lines <(xxd $1) <(xxd $2)
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
# starts gtkwave and opens the test dump file in the current folder
|
| 198 |
+
function gw {
|
| 199 |
+
local DIR=$(basename $(pwd))
|
| 200 |
+
local DMPFILE=
|
| 201 |
+
local FOUND=0
|
| 202 |
+
if [ -e test.gtkw ]; then DMPFILE=$DIR/test.gtkw; fi
|
| 203 |
+
for ext in lxt fst vcd; do
|
| 204 |
+
if [ -e test.$ext ]; then
|
| 205 |
+
# starts from .. so the folder name is shown on
|
| 206 |
+
# GTKWave's title bar
|
| 207 |
+
(cd ..; gtkwave $DIR/test.$ext $DMPFILE &)
|
| 208 |
+
FOUND=1
|
| 209 |
+
break
|
| 210 |
+
fi
|
| 211 |
+
done
|
| 212 |
+
if [ $FOUND = 0 ]; then
|
| 213 |
+
echo "No test.lxt, test.fst, test.vcd in the current folder"
|
| 214 |
+
return 1
|
| 215 |
+
fi
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
# set default jtframe target by calling the command-line target function
|
| 219 |
+
export TARGET=sidi128
|
| 220 |
+
function target {
|
| 221 |
+
if [ -z "$1" ]; then
|
| 222 |
+
echo $TARGET
|
| 223 |
+
return 0
|
| 224 |
+
fi
|
| 225 |
+
if [ ! -d $JTFRAME/target/$1 ]; then
|
| 226 |
+
echo "$1 is not a valid JTFRAME target"
|
| 227 |
+
return 1
|
| 228 |
+
fi
|
| 229 |
+
export TARGET=$1
|
| 230 |
+
echo $TARGET
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
# check that git hooks are present
|
| 234 |
+
for HOOK in $JTFRAME/bin/hooks/*; do
|
| 235 |
+
cp --update $HOOK $(git rev-parse --git-path hooks)
|
| 236 |
+
done
|
| 237 |
+
|
| 238 |
+
if ! git config -l | grep instead > /dev/null; then
|
| 239 |
+
cat<<EOF
|
| 240 |
+
Consider executing:
|
| 241 |
+
git config --global url.ssh://git@github.com/.insteadOf https://github.com/
|
| 242 |
+
|
| 243 |
+
in order to avoid the need for GitHub tokens when pushing submodules
|
| 244 |
+
EOF
|
| 245 |
+
fi
|
snapshots/jotego_jtcores_pr1101/modules/jtframe/bin/sim-all-scenes.sh
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# simulate all scenes in the folders below
|
| 3 |
+
|
| 4 |
+
set -e
|
| 5 |
+
RUN_FOLDER=`mktemp`
|
| 6 |
+
|
| 7 |
+
cat > $RUN_FOLDER <<EOF
|
| 8 |
+
#!/bin/bash
|
| 9 |
+
cd \$1
|
| 10 |
+
pwd
|
| 11 |
+
SIM=jtsim
|
| 12 |
+
if [ -e sim.sh ]; then
|
| 13 |
+
SIM=sim.sh
|
| 14 |
+
fi
|
| 15 |
+
for SCN in \`find scenes -maxdepth 1 -mindepth 1 -type d | xargs -l1 basename\`; do
|
| 16 |
+
\$SIM -batch -s \$SCN
|
| 17 |
+
done
|
| 18 |
+
EOF
|
| 19 |
+
chmod +x $RUN_FOLDER
|
| 20 |
+
|
| 21 |
+
for EACH in `find -type d -name scenes`; do
|
| 22 |
+
if [ ! -z "$GAME" ]; then GAME="$GAME "; fi
|
| 23 |
+
GAME="${GAME}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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -e
|
| 2 |
+
# use to simulate unit tests
|
| 3 |
+
# create a file called gather.f with the names of the files to include in the sim
|
| 4 |
+
# not local to the simulation folder
|
| 5 |
+
|
| 6 |
+
main() {
|
| 7 |
+
parse_args $*
|
| 8 |
+
cd_to_run_folder
|
| 9 |
+
parse_dot_simunit
|
| 10 |
+
if [ -z "$ALL_MACROS" ]; then
|
| 11 |
+
run_one
|
| 12 |
+
else
|
| 13 |
+
loop_macros
|
| 14 |
+
fi
|
| 15 |
+
exit_with_status
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
parse_args() {
|
| 19 |
+
RUNFOLDER="."
|
| 20 |
+
ALL_MACROS=
|
| 21 |
+
MACRO=
|
| 22 |
+
FAIL=0
|
| 23 |
+
while [ $# -gt 0 ]; do
|
| 24 |
+
case "$1" in
|
| 25 |
+
--keep) KEEP_LXTFILE=1;;
|
| 26 |
+
--run) shift; RUNFOLDER="$1";;
|
| 27 |
+
--macros) shift; ALL_MACROS="$1";;
|
| 28 |
+
--help|-h) show_help; exit 0;;
|
| 29 |
+
*)
|
| 30 |
+
echo "Unsupported argument $1"
|
| 31 |
+
exit 1;;
|
| 32 |
+
esac
|
| 33 |
+
shift
|
| 34 |
+
done
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
show_help() {
|
| 38 |
+
cat <<EOF
|
| 39 |
+
simunit.sh: run unit simulations
|
| 40 |
+
|
| 41 |
+
--keep do not delete test.lxt after a PASS simulation
|
| 42 |
+
--macros comma separated list of macros. Each macro will trigger a different
|
| 43 |
+
simulation.
|
| 44 |
+
--run sets run folder
|
| 45 |
+
--help, -h this help
|
| 46 |
+
EOF
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
parse_dot_simunit() {
|
| 50 |
+
if [ -s .simunit ]; then
|
| 51 |
+
local top_line
|
| 52 |
+
top_line=`head --lines 1 .simunit`
|
| 53 |
+
parse_args $top_line
|
| 54 |
+
fi
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
run_one() {
|
| 58 |
+
prepare_files
|
| 59 |
+
lint_uut
|
| 60 |
+
run_simulation
|
| 61 |
+
eval_result
|
| 62 |
+
clean_up
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
loop_macros() {
|
| 66 |
+
for MACRO in `expand_comma_list $ALL_MACROS`; do
|
| 67 |
+
printf "%-32s" "$MACRO"
|
| 68 |
+
run_one
|
| 69 |
+
done
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
expand_comma_list() {
|
| 73 |
+
local list="$1"
|
| 74 |
+
echo $list | tr , ' '
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
cd_to_run_folder() {
|
| 78 |
+
if [ -z "$RUNFOLDER" ]; then
|
| 79 |
+
RUNFOLDER=`pwd`
|
| 80 |
+
fi
|
| 81 |
+
|
| 82 |
+
cd $RUNFOLDER
|
| 83 |
+
echo "Running from `pwd`"
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
prepare_files() {
|
| 87 |
+
GATHER=`mktemp`
|
| 88 |
+
envsubst < gather.f > $GATHER
|
| 89 |
+
echo >> $GATHER # extra blank line
|
| 90 |
+
copy_hex_files
|
| 91 |
+
filter_hex_out
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
lint_uut() {
|
| 95 |
+
local macro
|
| 96 |
+
if [ ! -z "$MACRO" ]; then
|
| 97 |
+
macro="-D$MACRO"
|
| 98 |
+
fi
|
| 99 |
+
local top
|
| 100 |
+
top=`get_top_module`
|
| 101 |
+
if [[ $macro != *JTFRAME_MCLK* ]]; then
|
| 102 |
+
macro="$macro -DJTFRAME_MCLK=48000000"
|
| 103 |
+
fi
|
| 104 |
+
verilator --lint-only -f $GATHER --top-module $top $macro
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
get_top_module() {
|
| 108 |
+
local top_line filename module
|
| 109 |
+
top_line=`head -n 1 $GATHER`
|
| 110 |
+
filename=`basename $top_line`
|
| 111 |
+
module=${filename%.*}
|
| 112 |
+
echo $module
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
copy_hex_files() {
|
| 116 |
+
for i in `grep hex$ $GATHER`; do
|
| 117 |
+
cp $i .
|
| 118 |
+
done
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
filter_hex_out() {
|
| 122 |
+
sed -i /hex$/d $GATHER
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
run_simulation() {
|
| 126 |
+
local macro
|
| 127 |
+
if [ ! -z "$MACRO" ]; then
|
| 128 |
+
macro="-D $MACRO"
|
| 129 |
+
fi
|
| 130 |
+
if [[ $macro != *JTFRAME_MCLK* ]]; then
|
| 131 |
+
macro="$macro -D JTFRAME_MCLK=48000000"
|
| 132 |
+
fi
|
| 133 |
+
iverilog -g2012 `find -name "*.v"` `find -name "*.sv"` \
|
| 134 |
+
-I$JTFRAME/ver/inc \
|
| 135 |
+
$JTFRAME/hdl/{video/jtframe_vtimer.v,ver/jtframe_test_clocks.v} \
|
| 136 |
+
-f$GATHER -s test -o sim -D SIMULATION $macro
|
| 137 |
+
sim -lxt > sim.log
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
eval_result() {
|
| 141 |
+
if grep PASS sim.log > /dev/null; then
|
| 142 |
+
echo PASS
|
| 143 |
+
else
|
| 144 |
+
cat sim.log
|
| 145 |
+
echo FAIL
|
| 146 |
+
FAIL=1
|
| 147 |
+
fi
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
clean_up() {
|
| 151 |
+
rm -f sim $GATHER sim.log
|
| 152 |
+
if [[ $FAIL = 0 && -z "$KEEP_LXTFILE" ]]; then
|
| 153 |
+
rm -f test.lxt
|
| 154 |
+
fi
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
exit_with_status() {
|
| 158 |
+
if [ $FAIL = 1 ]; then
|
| 159 |
+
exit 1;
|
| 160 |
+
else
|
| 161 |
+
exit 0
|
| 162 |
+
fi
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
main $*
|