Last active
January 8, 2020 06:01
-
-
Save ryu10/1c138c5789a46790eb8fc3a76d335b65 to your computer and use it in GitHub Desktop.
Modified from MUTIF09Project/Am9511A-AddonBoard/TestProgram/asciiart/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 CLEAR 300,&H7000 : REM TOP | |
3 PRINT "LOADING MACHINE CODE..." | |
4 GOSUB 1000 | |
5 PRINT "FINISHED." : PRINT "INITIALIZING..." | |
6 EXEC &H7119 : REM INIT | |
7 PRINT "INIT DONE." | |
10 FOR Y=0 TO 24 | |
15 POKE &H718A,Y : REM VARY LSB | |
20 FOR X=0 TO 78 | |
25 POKE &H7186,X : REM VARX LSB | |
65 EXEC &H7000 : REM L30_60 | |
70 FOR I=0 TO 15 | |
105 EXEC &H7061 : REM L80_110 | |
115 IF PEEK(&H719F)>127 THEN GOTO 200 | |
120 NEXT I | |
130 PRINT " "; | |
140 GOTO 210 | |
200 IF I>9 THEN I=I+7 | |
205 PRINT CHR$(48+I); | |
210 NEXT X | |
220 PRINT | |
230 NEXT Y | |
240 END | |
1000 REM | |
1010 A=&H7000 : REM TOP | |
1020 READ D$ | |
1030 IF D$="**" THEN RETURN | |
1040 POKE A,VAL("&H"+D$) | |
1050 A=A+1 | |
1060 GOTO 1020 | |
1070 REM | |
2010 DATA 30,8D,01,67,17,01,27,30 | |
2020 DATA 8D,01,78,17,01,20,30,8D | |
2030 DATA 01,69,17,01,19,17,00,F9 | |
2040 DATA 17,00,DA,17,00,DF,30,8D | |
2050 DATA 01,69,17,01,20,30,8D,01 | |
2060 DATA 46,17,01,02,30,8D,01,57 | |
2070 DATA 17,00,FB,30,8D,01,48,17 | |
2080 DATA 00,F4,17,00,D4,17,00,B5 | |
2090 DATA 17,00,BA,30,8D,01,48,17 | |
2100 DATA 00,FB,30,8D,01,3D,31,8D | |
2110 DATA 01,41,17,01,05,30,8D,01 | |
2120 DATA 36,31,8D,01,3A,17,00,FA | |
2130 DATA 39,30,8D,01,2E,17,00,C6 | |
2140 DATA 17,00,8E,17,00,8F,30,8D | |
2150 DATA 01,25,17,00,B9,17,00,81 | |
2160 DATA 17,00,82,17,00,8B,30,8D | |
2170 DATA 01,09,17,00,A9,17,00,79 | |
2180 DATA 30,8D,01,0F,17,00,B6,30 | |
2190 DATA 8D,00,E0,17,00,98,30,8D | |
2200 DATA 00,F9,17,00,91,30,8D,00 | |
2210 DATA F6,17,00,8A,8D,57,8D,55 | |
2220 DATA 30,8D,00,E3,17,00,7F,8D | |
2230 DATA 50,30,8D,00,E2,17,00,8D | |
2240 DATA 30,8D,00,DF,31,8D,00,D3 | |
2250 DATA 17,00,97,30,8D,00,CC,8D | |
2260 DATA 65,8D,2E,8D,30,30,8D,00 | |
2270 DATA C6,8D,5B,8D,24,8D,26,8D | |
2280 DATA 28,30,8D,00,9A,8D,4F,8D | |
2290 DATA 28,8D,32,30,8D,00,B8,8D | |
2300 DATA 5C,39,B7,B0,05,B6,B0,05 | |
2310 DATA 85,80,26,F9,39,86,1C,20 | |
2320 DATA F1,86,17,20,ED,86,12,20 | |
2330 DATA E9,86,10,20,E5,86,1E,20 | |
2340 DATA E1,86,11,20,DD,86,1A,20 | |
2350 DATA D9,86,2D,20,D5,86,15,20 | |
2360 DATA D1,86,80,B7,B0,13,86,01 | |
2370 DATA B7,B0,12,1F,11,1F,11,1F | |
2380 DATA 11,4F,B7,B0,12,39,30,04 | |
2390 DATA A6,82,B7,B0,04,A6,82,B7 | |
2400 DATA B0,04,A6,82,B7,B0,04,A6 | |
2410 DATA 82,B7,B0,04,39,B6,B0,04 | |
2420 DATA A7,80,B6,B0,04,A7,80,B6 | |
2430 DATA B0,04,A7,80,B6,B0,04,A7 | |
2440 DATA 80,39,A6,80,A7,A0,A6,80 | |
2450 DATA A7,A0,A6,80,A7,A0,A6,80 | |
2460 DATA A7,A0,39,7C,BB,98,C8,7D | |
2470 DATA AA,A8,EB,02,80,00,00,03 | |
2480 DATA 80,00,00,00,00,00,27,00 | |
2490 DATA 00,00,0C,00,00,00,00,00 | |
2500 DATA 00,00,00 | |
2510 DATA 00,00,00,00 | |
2520 DATA ** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Subroutine for asciiart.bas | |
* | |
* make sure to connect RESET pin of Am9511A to PC0 pin of 8255A | |
* | |
APUDA EQU $B004 | |
APUCS EQU $B005 | |
PPIPA EQU $B010 | |
PPIPB EQU $B011 | |
PPIPC EQU $B012 | |
PPICS EQU $B013 | |
* | |
CMD_PTOF EQU $17 ;TOS is copied into the new TOS location | |
CMD_FMUL EQU $12 | |
CMD_FSUB EQU $11 | |
CMD_FADD EQU $10 | |
CMD_FIXD EQU $1E ;32-bit floating point to 32-bit fixed point | |
CMD_FLTD EQU $1C ;32-bit fixed point to 32-bit floating point ; | |
CMD_PUPI EQU $1A ;push 32-bit floating-point pi | |
CMD_DSUB EQU $2D | |
CMD_CHSF EQU $15 ; change sign of fp on TOS | |
* | |
ORG $7000 | |
* | |
*30 CA=X*0.0458 | |
*40 CB=Y*0.08333 | |
*50 A=CA | |
*60 B=CB | |
* | |
L30_60 LEAX C0458,PCR ;30 CA=(X-39)*0.0458 | |
LBSR LOAD | |
LEAX VARX,PCR | |
LBSR LOAD | |
LEAX C39D,PCR | |
LBSR LOAD | |
LBSR DSUB | |
LBSR FLTD | |
LBSR FMUL | |
LEAX VARCA,PCR | |
LBSR STORE | |
LEAX C0833,PCR ;40 CB=(Y-12)*0.08333 | |
LBSR LOAD | |
LEAX VARY,PCR | |
LBSR LOAD | |
LEAX C12D,PCR | |
LBSR LOAD | |
LBSR DSUB | |
LBSR FLTD | |
LBSR FMUL | |
LEAX VARCB,PCR | |
LBSR STORE | |
LEAX VARCA,PCR ;50 A=CA | |
LEAY VARA,PCR | |
LBSR ASSIGN | |
LEAX VARCB,PCR ;60 B=CB | |
LEAY VARB,PCR | |
LBSR ASSIGN | |
RTS | |
* | |
*80 T=A*A-B*B+CA | |
*90 B=2*A*B+CB | |
*100 A=T | |
* | |
L80_110 LEAX VARA,PCR ;80 T=A*A-B*B+CA | |
LBSR LOAD | |
LBSR PTOF | |
LBSR FMUL | |
LEAX VARB,PCR | |
LBSR LOAD | |
LBSR PTOF | |
LBSR FMUL | |
LBSR FSUB | |
LEAX VARCA,PCR | |
LBSR LOAD | |
LBSR FADD | |
LEAX VART,PCR | |
LBSR STORE | |
LEAX C2,PCR ;90 B=2*A*B+CB | |
LBSR LOAD | |
LEAX VARA,PCR | |
LBSR LOAD | |
LEAX VARB,PCR | |
LBSR LOAD | |
BSR FMUL | |
BSR FMUL | |
LEAX VARCB,PCR | |
LBSR LOAD | |
BSR FADD | |
LEAX VARB,PCR | |
LBSR STORE | |
LEAX VART,PCR ;100 A=T | |
LEAY VARA,PCR | |
LBSR ASSIGN | |
* | |
*110 IF (A*A+B*B)>4 THEN GOTO 200 | |
* | |
LEAX VARA,PCR ; 4-A*A+B*B -> TMP | |
BSR LOAD ; IF(TMP<0) THEN 200 | |
BSR PTOF | |
BSR FMUL | |
LEAX VARB,PCR | |
BSR LOAD | |
BSR PTOF | |
BSR FMUL | |
BSR FADD | |
LEAX C4,PCR | |
BSR LOAD | |
BSR FSUB | |
BSR CHSF | |
LEAX TMP,PCR | |
BSR STORE | |
RTS | |
* | |
* Send command word and wait for the completion of the command | |
* On entry: A = command word | |
* On return: Accumulator A is altered by the subroutine | |
EXEC STA APUCS | |
WAIT LDA APUCS | |
BITA #%10000000 ;check for busy flag | |
BNE WAIT ;wait for completion of command execution | |
RTS ;return status in accumulator A | |
* | |
* 32-bit fixed point intger operand A at the TOS is converted to a 32-bit floating point number | |
* | |
FLTD LDA #CMD_FLTD | |
BRA EXEC | |
* | |
* The current TOS is copied into the TOS | |
* | |
PTOF LDA #CMD_PTOF | |
BRA EXEC | |
* | |
* 32-bit floating point operand A at the TOS is multiplied by the 32-bit floating point operand B at the NOS | |
* | |
FMUL LDA #CMD_FMUL | |
BRA EXEC | |
* | |
* 32-bit floating point operand A at the TOS is added to 32-bit floaring point operand B at the NOS | |
* | |
FADD LDA #CMD_FADD | |
BRA EXEC | |
* | |
* 32-bit floating point operand A at the TOS is converted to a 32-bit fixed point integer | |
* | |
FIXD LDA #CMD_FIXD | |
BRA EXEC | |
* | |
* 32-bit floating point operand A at the TOS is subtracted from 32-bit floating point operand B at the NOS | |
FSUB LDA #CMD_FSUB | |
BRA EXEC | |
* | |
* 32-bit floating point Pi is entered into TOS | |
* | |
PUPI LDA #CMD_PUPI | |
BRA EXEC | |
* | |
* 32-bit fixed point operand A at the TOS is subtracted from 32-bit fixed point operand B at the NOS | |
* | |
DSUB LDA #CMD_DSUB | |
BRA EXEC | |
* | |
* Change sign of 32-bit floating point operand on TOS | |
* | |
CHSF LDA #CMD_CHSF | |
BRA EXEC | |
* | |
* APU initialization | |
* On entry: no parameters required | |
* On return: Accumulator A and index register X are altered by the subroutine | |
* | |
INIT LDA #$80 ;condifure 8255A Port A, B and C (Px0 - Px7) for output | |
STA PPICS | |
LDA #$01 ;enter BSR mode. make PC0 high for resetting Am9511A | |
STA PPIPC ;RESET must be high for at least 5 CLK periods, as per datasheet of Am9511A | |
TFR X,X ;wait for 18 (= 6 x 3) cycles before end of reset | |
TFR X,X ;(assuming that E Clock from 6809 is fed to the CLK pin of Am9511A by default) | |
TFR X,X | |
CLRA ;make PC0 low. end of reset. The stack pointer of Am9511 is now (re-)initialized | |
STA PPIPC | |
RTS | |
* | |
* Load APU stack | |
* On entry: X = pointer to the floating point constant or variable | |
* On return: Accumulator A is altered by the subroutine | |
* | |
LOAD LEAX 4,X | |
LDA ,-X | |
STA APUDA | |
* NOP | |
LDA ,-X | |
STA APUDA | |
* NOP | |
LDA ,-X | |
STA APUDA | |
* NOP | |
LDA ,-X | |
STA APUDA | |
* NOP | |
RTS | |
* | |
* Read data from APU stack and store them | |
* On entry: X = pointer to the floatinig point variable | |
* On return: Accumulator A is altered by the subroutine | |
* | |
STORE LDA APUDA | |
* NOP | |
STA ,X+ | |
LDA APUDA | |
* NOP | |
STA ,X+ | |
LDA APUDA | |
* NOP | |
STA ,X+ | |
LDA APUDA | |
* NOP | |
STA ,X+ | |
RTS | |
* | |
* Assign data to variable specified | |
* X = pointer to the floating point constant or variable (source) | |
* Y = pointer to the floating point variable (destination) | |
* Accumulator A, index register X and Y are atlered by the subroutine | |
* | |
ASSIGN LDA ,X+ | |
STA ,Y+ | |
LDA ,X+ | |
STA ,Y+ | |
LDA ,X+ | |
STA ,Y+ | |
LDA ,X+ | |
STA ,Y+ | |
RTS | |
* | |
C0458 FCB $7C, $BB, $98, $C8 ;0.0458 | |
C0833 FCB $7D, $AA, $A8, $EB ;0.08333 | |
C2 FCB $02, $80, $00, $00 ;2.0 | |
C4 FCB $03, $80, $00, $00 ;4.0 | |
C39D FCB 0, 0, 0, 39 ;39 (fixed point integer. Most signigicant byte first) | |
C12D FCB 0, 0, 0, 12 ;12 (fixed point integer. Most signigicant byte first) | |
VARX FCB 0, 0, 0 ;fixed point integer | |
FCB 0 ;least signigicant byte | |
VARY FCB 0, 0, 0 ;fixed point integer | |
FCB 0 ;least signigicant byte | |
VARCA RMB 4 | |
VARCB RMB 4 | |
VARA RMB 4 | |
VARB RMB 4 | |
VART RMB 4 | |
TMP RMB 3 | |
RMB 1 ;least signigicant byte | |
* | |
END |
Author
ryu10
commented
Jan 7, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment