-
Notifications
You must be signed in to change notification settings - Fork 0
/
7501.asm
8301 lines (7859 loc) · 270 KB
/
7501.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
* :ts=8 7501.asm
*
* cp4 - Commodore C+4 emulator
* Copyright (C) 1998 Gáti Gergely
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* e-mail: [email protected]
*
*
* 7501 CPU emu + TED
*
include "exec/types.i"
include "exec/macros.i"
include "exec/execbase.i"
include "exec/nodes.i"
include "lvos/exec_lib.i"
include "lvos/intuition_lib.i"
include "hardware/intbits.i"
include "iec/iec.i"
include "iec/iec_lib.i"
include "c2p_module.i"
include "libraries/playsidbase.i"
include "libraries/playsid_lib.i"
include "shadow.i"
include "stat.i"
* d0 - WORK, byte only!! (000000xx)
* d1 - WORK, word only!! (0000xxxx)
* 31 23 15 7 0
RA EQUR d2 * ACCU |....:....|....:....|..1.:....|....:....|
* 0000 0000 modeflag nV-B DIzc ACCU
RX EQUR d3 * X-REG (1...00xx)
* ^stopcnt1
RY EQUR d4 * Y-REG (____00yy)
* ^p4actras.w
*-----------------------------------------------------------------------------
* STATUS FLAGS:
* 31 23 15 7 0
RP EQUR d5 * FLAGS |....:....|....:....|....:....|....:....|
* 3GOR PICS 7RND FB.. 0000 0000 Amiga-CCR
* ^ stopcnt3
* ^*Kellgfx flag
* ^*CntIrq
* ^ raster_enable
* -^*iec? (1-ok)
* ^ oldirq
* ^ singleclk (=1)
* ^*sound_enable
* -^ 7.bit off=0
* ^ actramrom (1-rom)
* ^ Normal-cnt
* ^*SID? (1-yes)
* ^ render? (1-yes)
* ^ border? (0-no)
* (*) : stay when restore a snapshot
* ( ) : replace when restore
*
* test CARRY:
* move.w RSP,CCR
* bcs .carry_set
* test OVERFLOW:
* btst #B_OVER,RA
* bne .overflow_set
* test BREAK:
* btst #B_BRK,RA
* bne .break_set
* test DECIMAL:
* btst #B_DEC,RA
* bne .decimal_set
* test INTERRUPT:
* btst #B_IRQ,RA
* bne .interrupt_set
* test ZERO:
* move.w RP,CCR
* beq .zero_set
* test NEGATIVE:
* move.w RP,CCR
* bmi .negative_set
*------------------------------------------------------------------------------
RSP EQUR d6 * STACK POINTER (01xx....) ~(low word: ACCR-Carry)
CYC EQUR d7 * gfxclock (2...0cyc)
* ^stopcnt2
RAM EQUR a2 * RAM POINTER (FIX RAM!!)
HIRAM EQUR a3 * RAM/ROM POINTER
FETCH EQUR a4 * fetchtable-pointer
DOGFX EQUR a5 * dogfx()
RPC EQUR a6 * PC (amiga&c+4)
;--------------------------------------------------------------------------------
;XREFs NAME TYPE
;--------------------------------------------------------------------------------
xref _opt_twoscr * l
xref _myram * *b
xref _hiram * *b
xref _r_a * b
xref _r_x * b
xref _r_y * b
xref _r_sp * b
xref _r_pc * w
xref _r_p * b
xref _countpointer * *int
xref _brcntpnt * *int
xref _SysBase * *
* TED
xref _colback * b
xref _colbord * b
xref _colbordlong * l
xref _col1 * b
xref _col2 * b
xref _col3 * b
xref _clp1 * *b
xref _clp2 * *b
xref _clp3 * *b
xref _col * col[]
xref _rasreq * w
xref _ec1 * b
xref _ec2 * b
xref _ec3 * b
xref _colplace * l
xref _textplace * l
xref _actcharaddr * l
xref _p4actras * l
xref _actinchar * l
xref _p4rom * l
xref _backtable * *b
xref _coltable * *b
xref _vscroll * l
xref _tbordminus * l
xref _numraster * l
xref _userblank * b
xref _modeflag * b
xref _modegfx * *func[]
xref _dogfx * *func
xref _opt_border * b (ted.c) 0-nem kell border
xref _hscroll * l
xref _leftborder * l
xref _rightborder * l
xref _cols * l
xref _sideborders * l
xref _offscr * l
xref _curpos * l
xref _cureor * b
xref _gfxaddr * w
xref _charmap * *b
xref _keymatrixp * *b
xref _actrom * b
xref _romtab * *b
xref _romsp0 * *b
xref _romsp1 * *b
xref _romsp2 * *b
xref _romsp3 * *b
xref _romsp4 * *b
xref _romsp5 * *b
xref _romsp6 * *b
xref _romsp7 * *b
xref _doframe * func
xref _actraster * l
xref _setchannel1 * func
xref _setchannel2 * func
xref _setch2quad * func
xref _setch2noise * func
xref _opt_nosound * l (0-snd on)
xref _setbit7on * func
xref _setbit7off * func (d0==0 ch2 quad)
xref _setbit7 * func
xref _snd_7bit * *b (/w) (4byte sample buffer)
xref _IECBase * libbase
xref _IntuitionBase * libbase
xref _p4req1 * func (p4req.c)
xref _cp4prefsmpmakesnapshot * func (preferencesgui.c)
xref _cp4prefsmploadsnapshot * func (preferencesgui.c)
xdef _CodeTab * l[]
* scans.asm
xref ctabdouble * l[]
xref ctabsingle * l[]
xref ctabblankdouble * l[]
xref ctabblanksingle * l[]
* debug
xref _dbgmodeflag * b
xref _dbgamiras * l
xref _dbgrasreq * w
xref _dbgvideo * w
xref _dbggfxbase * w
xref _dbgeirq * b
xref _dbgp4ras * w
xref _dodebug * func
xref _amirasaddr * l (ted.c)
* c2p
xref _c2pact * *func
xref _c2pv * *struct
* prefs
xref _prefsguis * func
xref _ptwoframe * l
xref _pswapjoy * l
xref _plimit * l
xref _pc2p * l
xref _pscr * l
* realtime
xref _skipflag * bw
* SID
xref _opt_sid * l
xref _opt_sidtype * l
xdef _initsid * func
xdef _endsid * func
xdef _sidpause * func
xdef _sidresume * func
xdef _PlaySidBase *
xdef _6581sidBase *
* NoRender video
xref _c2pColor * *b
xref _c2pVideo * *b
xref _c2pGfx * *b
xref _c2pModeflag * b
xref _opt_render * l (0-nem renderel)
* for direct mode
xref _opt_direct * l cp4.c (0-nincs)
* for IEC emu
xref _opt_iec * l cp4.c (0-nincs)
xref _pin_PIEC_W * func pin_piec.c
xref _pin_PIEC_Reset * func pin_piec.c
xref _rmode * b (1-noflip 0-normal)
xref _pin_IEC_W * func pin_iec.c
xref _pin_IEC_R * func pin_iec.c
xref _pin_IEC_Reset * func pin_iec.c
xref _ieccntflag * b pin_iec.c
IFD STAT_IEC
xref _iecmessage * func (iectrace)
IM_CIOUT EQU 1
IM_TALK EQU 2
IM_LISTEN EQU 3
IM_UNTALK EQU 4
IM_UNLISTEN EQU 5
IM_ACPTR EQU 6
IM_SEC EQU 7
IM_TKSA EQU 8
ENDIF
F_NEG EQU $8000
F_OVER EQU $4000
F__ EQU $2000 ; always 1
F_BRK EQU $1000
F_DEC EQU $800
F_IRQ EQU $400
F_ZERO EQU $200
F_CARRY EQU $100
B_NEG EQU 15
B_OVER EQU 14
B__ EQU 13
B_BRK EQU 12
B_DEC EQU 11
B_IRQ EQU 10
B_ZERO EQU 9
B_CARRY EQU 8
* SIDTYPE
SIDTYPE_NONE EQU 0
SIDTYPE_PSID EQU 1
SIDTYPE_6581 EQU 2
* 6581sid.library
_LVOSID_AllocSID EQU -30
_LVOSID_FreeSID EQU -36
_LVOSID_Interrupt EQU -42
_LVOSID_Initialize EQU -48
_LVOSID_ResetSID EQU -54
_LVOSID_IRQOnOff EQU -60
_LVOSID_ReadReg EQU -72
_LVOSID_WriteReg EQU -78
* SID Handle structure
sid_Enabled EQU 4
sid_Filter EQU 5
sid_60Hz EQU 6
sid_RingQual EQU 7
sid_SyncQual EQU 8
sid_ADSRQual EQU 13
sid_IRQRate EQU 18
*
* modeflag az RA tetjén (on the top of RA)
*
MODEINIT EQU $10
M_MULTI EQU 16
M_BITMAP EQU 17
M_EXTCOL EQU 18
M_INV EQU 19
M_SCROFF EQU 20
M_FLASH EQU 21
M_UBLANK EQU 22
* or-values (swapped!)
ORMULTI EQU 1
ORBITMAP EQU 2
OREXTCOL EQU 4
ORINV EQU 8
ORSCROFF EQU 16
ORFLASH EQU 32
ORUBLANK EQU 64
* az RX tetején (top of RX)
STOPCNT1 EQU 31
* az CYC tetején (top of CYC)
STOPCNT2 EQU 31
*
* bitek az RP tetején (bits on the top of RP)
*
STOPCNT3 EQU 31
KELLGFX EQU 30
CNTIRQ EQU 29
ERAS EQU 28
IEC EQU 27
OLDIRQ EQU 26
SNGCLK EQU 25
NOSND EQU 24
BIT7OFF EQU 23
ACTRAMROM EQU 22
NRMCNT EQU 21
SKIPIT EQU 20
SID EQU 19
RENDER EQU 18
BORDER EQU 17
* or/and-elhetõ értékek: (or/and-able values)
M_STOPCNT3 EQU $80000000
M_KELLGFX EQU $40000000
M_CNTIRQ EQU $20000000
M_ERAS EQU $10000000
M_IEC EQU $08000000
M_OLDIRQ EQU $04000000
M_SNGCLK EQU $02000000
M_NOSND EQU $01000000
M_BIT7OFF EQU $00800000
M_ACTRAMROM EQU $00400000
M_NRMCNT EQU $00200000
M_SKIPIT EQU $00100000
M_SID EQU $00080000
M_RENDER EQU $00040000
M_BORDER EQU $00020000
*
* konstansok
*
CLKFAST EQU 109 ; doksiból (from doc)
* eye corrected
CLKSLOW EQU 53 ; doksiból-korrigálva szemmel (60-58)
* time delay for iec-patch
T_TALK EQU 150
T_LISTEN EQU 140
T_UNTALK EQU 150
T_UNLISTEN EQU 150
T_OUT EQU 110
T_IN EQU 110
T_SECOND EQU 90
T_SECTALK EQU 90
* IEC_Types
IT_NONE EQU 0
IT_IEC EQU 1
IT_SOFT EQU 2
* MAIN
xdef _asmexecute *Func
xdef _StatTab *statistic
* SNAPSHOT-FILE
xdef _sfrd2 *l
xdef _sfrd3 *l
xdef _sfrd4 *l
xdef _sfrd5 *l
xdef _sfrd6 *l
xdef _sfrd7 *l
xdef _sft1 *w
xdef _sfpc *w
xdef _sfc1 *w
xdef _sfc2 *w
xdef _sfc3 *w
xdef _sfac *w
xdef _sfc1c *w
xdef _sfc2c *w
xdef _sfc3c *w
xdef _sfchr *b
xdef _sfchm *l
*-------------------------------------------------------------------------
* libcall macro
*-------------------------------------------------------------------------
LIBCALL MACRO ;FunctionName
jsr _LVO\1(a6)
ENDM
*-------------------------------------------------------------------------
* libcall macro with base init
*-------------------------------------------------------------------------
LIBCALLB MACRO ;FunctionName,Base
move.l \2,a6
jsr _LVO\1(a6)
ENDM
*-------------------------------------------------------------------------
* shadowcvars
*-------------------------------------------------------------------------
shadowcvars MACRO
move.l _actraster,MY_actraster(a1)
move.l _actinchar,MY_actinchar(a1)
move.l _actcharaddr,MY_actcharaddr(a1)
* ez word!!!
* move.l _rasreq,MY_rasreq(a1)
move.w _rasreq,MY_rasreq(a1)
move.l _numraster,MY_numraster(a1)
move.l _charmap,MY_charmap(a1)
move.l _vscroll,MY_vscroll(a1)
move.l _colplace,MY_colplace(a1)
move.l _textplace,MY_textplace(a1)
move.l _curpos,MY_curpos(a1)
move.l _leftborder,MY_leftborder(a1)
move.l _backtable,MY_backtable(a1)
move.b _colback,MY_colback(a1)
move.l _coltable,MY_coltable(a1)
move.w _gfxaddr,MY_gfxaddr(a1)
move.b _col1,MY_col1(a1)
move.b _col2,MY_col2(a1)
move.b _col3,MY_col3(a1)
move.b _actrom,MY_actrom(a1)
move.l _hscroll,MY_hscroll(a1)
* ONLY_STORE
move.l _keymatrixp,MY_keymatrixp(a1)
move.l _p4rom,MY_p4rom(a1)
bset #BORDER,RP
tst.b _opt_border
bne \@1$
bclr #BORDER,RP
\@1$
ENDM
*-------------------------------------------------------------------------
* restoresomevars (work: d0.l)
*-------------------------------------------------------------------------
restoresomevars MACRO
move.l MY_charmap(a1),_charmap
move.l MY_curpos(a1),_curpos
move.l RAM,d0
move.w MY_colplace+2(a1),d0
move.l d0,_c2pColor
move.w MY_textplace+2(a1),d0
move.l d0,_c2pVideo
move.w MY_gfxaddr(a1),d0
move.l d0,_c2pGfx
swap RA
move.b RA,_c2pModeflag
swap RA
ENDM
*-------------------------------------------------------------------------
* restorecvars
*-------------------------------------------------------------------------
restorecvars MACRO
move.l MY_actraster(a1),_actraster
move.l MY_actinchar(a1),_actinchar
move.l MY_actcharaddr(a1),_actcharaddr
* Ez word!!!
* move.l MY_rasreq(a1),_rasreq
move.w MY_rasreq(a1),_rasreq
move.l MY_numraster(a1),_numraster
move.l MY_charmap(a1),_charmap
move.l MY_vscroll(a1),_vscroll
move.l MY_colplace(a1),_colplace
move.l MY_textplace(a1),_textplace
move.l MY_curpos(a1),_curpos
move.l MY_leftborder(a1),_leftborder
move.l MY_backtable(a1),_backtable
move.b MY_colback(a1),_colback
move.l MY_coltable(a1),_coltable
move.w MY_gfxaddr(a1),_gfxaddr
move.b MY_col1(a1),_col1
move.b MY_col2(a1),_col2
move.b MY_col3(a1),_col3
move.b MY_actrom(a1),_actrom
move.l MY_hscroll(a1),_hscroll
swap RA
move.b RA,_modeflag
swap RA
ENDM
*-------------------------------------------------------------------------
* set full c2p
*-------------------------------------------------------------------------
fullc2p MACRO
move.l _c2pv,a0
move.l C2PV_DOFULL(a0),_c2pact ; offset in struct
ENDM
*-------------------------------------------------------------------------
* set delta c2p
*-------------------------------------------------------------------------
deltac2p MACRO
move.l _c2pv,a0
move.l C2PV_DO(a0),_c2pact ; offset in struct
ENDM
*-------------------------------------------------------------------------
* WORK: a0
* test IECBase & patch ROM
*-------------------------------------------------------------------------
testiec MACRO
move.l a0,-(sp)
bclr #IEC,RP
move.l #ldazp,i_lda1
move.l #ldazp,i_lda2
move.l #stazp,i_sta1
move.l #stazp,i_sta2
tst.l _opt_iec
beq \@1$
move.l #ldazpT,i_lda1
move.l #ldazpT,i_lda2
move.l #stazpT,i_sta1
move.l #stazpT,i_sta2
bset #IEC,RP
\@1$ move.l (sp)+,a0
ENDM
*OLD version (rom patch)
** patch rom
* move.l _romsp0,a0
* move.w #$1200,$e153-$8000(a0) ; talk
* move.w #$1201,$e156-$8000(a0) ; listen
* move.w #$1202,$e177-$8000(a0) ; out
* move.w #$1202,$e181-$8000(a0) ; out
* move.w #$1203,$e1f7-$8000(a0) ; second
* move.w #$1204,$e203-$8000(a0) ; sectalk
* move.w #$1205,$e22f-$8000(a0) ; untalk
* move.w #$1206,$e23d-$8000(a0) ; unlisten
* move.w #$1207,$e252-$8000(a0) ; in
* move.l _p4rom,a0
* add.l #$8000,a0
* move.w #$1200,$e153-$8000(a0) ; talk
* move.w #$1201,$e156-$8000(a0) ; listen
* move.w #$1202,$e177-$8000(a0) ; out
* move.w #$1202,$e181-$8000(a0) ; out
* move.w #$1203,$e1f7-$8000(a0) ; second
* move.w #$1204,$e203-$8000(a0) ; sectalk
* move.w #$1205,$e22f-$8000(a0) ; untalk
* move.w #$1206,$e23d-$8000(a0) ; unlisten
* move.w #$1207,$e252-$8000(a0) ; in
* bra \@2$
** repatch rom
*\@1$ move.l _romsp0,a0
* move.w #$0940,$e153-$8000(a0) ; talk
* move.w #$0920,$e156-$8000(a0) ; listen
* move.w #$7820,$e177-$8000(a0) ; out
* move.w #$7820,$e181-$8000(a0) ; out
* move.w #$8595,$e1f7-$8000(a0) ; second
* move.w #$8595,$e203-$8000(a0) ; sectalk
* move.w #$7820,$e22f-$8000(a0) ; untalk
* move.w #$a93f,$e23d-$8000(a0) ; unlisten
* move.w #$78a9,$e252-$8000(a0) ; in
* move.l _p4rom,a0
* add.l #$8000,a0
* move.w #$0940,$e153-$8000(a0) ; talk
* move.w #$0920,$e156-$8000(a0) ; listen
* move.w #$7820,$e177-$8000(a0) ; out
* move.w #$7820,$e181-$8000(a0) ; out
* move.w #$8595,$e1f7-$8000(a0) ; second
* move.w #$8595,$e203-$8000(a0) ; sectalk
* move.w #$7820,$e22f-$8000(a0) ; untalk
* move.w #$a93f,$e23d-$8000(a0) ; unlisten
* move.w #$78a9,$e252-$8000(a0) ; in
*\@2$
* ENDM
*-------------------------------------------------------------------------
* WORK: d0.b
* nextst
*-------------------------------------------------------------------------
nextst MACRO * már a köv op-ra mutat az RPC
move.b (RPC)+,d0 * [RPC points to the next opcode]
IFD STAT
addq.l #1,(STAB,d0.l*4)
; codeview
move.w RPC,d1
lsr.w #8,d1 ; to 0-512
addq.l #1,(_CodeTab,d1.l*4)
ENDIF
jmp ([FETCH,d0.l*4])
ENDM
*-------------------------------------------------------------------------
* WORK:
* next \1: a csökkentés mértéke (cycle) (0-kimarad) [decrement value]
*-------------------------------------------------------------------------
next MACRO * már a köv op-ra mutat az RPC
IFNE \1 * [RPC points to the next opcode]
IFD STAT
addq.l #\1,STAC
ENDIF
subq.w #\1,CYC
bmi \@1$
ENDIF
nextst
IFNE \1
\@1$ bra raster
ENDIF
ENDM
*-------------------------------------------------------------------------
* WORK:
* next2 elõre csökkentett CYC-t vár, leteszteli. [no decrement but tst]
*-------------------------------------------------------------------------
next2 MACRO * már a köv op-ra mutat az RPC
tst.w CYC * [RPC points to the next opcode]
bmi \@1$
nextst
\@1$ bra raster
ENDM
*-------------------------------------------------------------------------
* WORK: -
* makerp - a saját STATUS-ból c+4 status-t készít [conv own ST 2 c+4 st]
*-------------------------------------------------------------------------
makerp MACRO
and.w #~(F_CARRY+F_NEG+F_ZERO),RA
move.w RSP,CCR
bcc \@1$
or.w #F_CARRY,RA
\@1$ move.w RP,CCR
bpl \@2$
or.w #F_NEG,RA
move.w RP,CCR
\@2$ bne \@3$
or.w #F_ZERO,RA
\@3$
ENDM
*-------------------------------------------------------------------------
* WORK: -
* makeccr - c+4 státuszból a saját STATUS-ba [conv c+4 st 2 own ST]
*-------------------------------------------------------------------------
makeccr MACRO
or.w #F__,RA * F__ = 1 ( + set N flag)
move.w CCR,RP * Z=0, mert beállítottuk az F__-t
btst #B_ZERO,RA ; [Z=0, becouse we set F__]
beq \@1$
or.b #4,RP
\@1$ btst #B_CARRY,RA
sne RSP * My C,X flag
move.l #fetchtable,FETCH
btst #B_DEC,RA
beq \@2$
move.l #fetchtabledec,FETCH
\@2$
ENDM
*-------------------------------------------------------------------------
* WORK: -
* memreadnt d1: addr.w --> \1: data.b (high byte ???)
* \2: hány ciklusos az ut. [cycle of statement]
* >8000: 26 <8000: 22
*-------------------------------------------------------------------------
memreadnt MACRO
bpl \@1$ ; 4/6
cmp.w #$fd00,d1 ; 4
bhs \@4$ ; 4/6
move.b (HIRAM,d1.l),\1 ; 8
bra \@2$ ; 6
\@4$ moveq #\2,d0
bsr reg_read
IFNC "d0","\1"
move.b d0,\1
ENDIF
bra \@2$
\@1$ move.b (RAM,d1.l),\1 ; 8
\@2$
ENDM
*-------------------------------------------------------------------------
* WORK: -
* memreadf RPC: addr.w --> \1: data.b (high byte 00)
*-------------------------------------------------------------------------
memreadf MACRO
clr.l \1
move.b (RPC)+,\1
ENDM
*-------------------------------------------------------------------------
* WORK: -
* memreadfb RPC: addr.w --> \1: data.b
*-------------------------------------------------------------------------
memreadfb MACRO
move.b (RPC)+,\1
ENDM
*-------------------------------------------------------------------------
* WORK: -
* makepc d1: addr.w --> RPC amiga addr
*-------------------------------------------------------------------------
makepc MACRO
move.l RAM,RPC
tst.w d1
bpl \@1$
move.l HIRAM,RPC
\@1$ add.l d1,RPC
ENDM
*-------------------------------------------------------------------------
* WORK: -
* memreadword \1: addr.w --> \2: data.w
*-------------------------------------------------------------------------
memreadword MACRO
bpl \@1$
move.w (HIRAM,\1.l),\2
bra \@2$
\@1$ move.w (RAM,\1.l),\2
\@2$ rol.w #8,\2
ENDM
*-------------------------------------------------------------------------
* WORK: -
* memreadwordf RPC: addr.w --> \1: data.w
*-------------------------------------------------------------------------
memreadwordf MACRO
move.w (RPC)+,\1
rol.w #8,\1
ENDM
*-------------------------------------------------------------------------
* WORK: -
* memreadwordfnc RPC: addr.w --> \1: data.w
*-------------------------------------------------------------------------
memreadwordfnc MACRO
move.w (RPC),\1
rol.w #8,\1
ENDM
*-------------------------------------------------------------------------
* WORK: -
* memreadwordzp \1: addr.w --> \2: data.w
*-------------------------------------------------------------------------
memreadwordzp MACRO
move.w (RAM,\1.l),\2
rol.w #8,\2
ENDM
*-------------------------------------------------------------------------
* WORK: -
* memreadzp d1.w: addr --> \1: data.b
*-------------------------------------------------------------------------
memreadzp MACRO
move.b (RAM,d1.l),\1
ENDM
*-------------------------------------------------------------------------
* WORK: -
* memreadzpt d1.w: addr --> \1: data.b (with iec test)
*-------------------------------------------------------------------------
memreadzpt MACRO
cmp.b #$02,d1
bhs \@1$
bsr iec_read
\@1$ move.b (RAM,d1.l),\1
ENDM
*-------------------------------------------------------------------------
* WORK: - (ha \2==0 -> nem d0 a \1!) (\3: cycle!)
* memwrite d1: addr.w --> \1: data.b
*-------------------------------------------------------------------------
memwrite MACRO
cmp.w #$d400,d1
bhs \@1$
move.b \1,(RAM,d1.l)
next \3
\@1$
IFEQ \2
move.b \1,d0
ENDIF
IFD STAT
addq.l #\3,STAC
ENDIF
subq.w #\3,CYC
jmp ([RAM,d1.l*4])
ENDM
*-------------------------------------------------------------------------
* WORK: - (ha \2==0 -> nem d0 a \1!) (\3: cycle!)
* memwritezp d1: addr.w --> \1: data.b
*-------------------------------------------------------------------------
memwritezp MACRO
move.b \1,(RAM,d1.l)
next \3
ENDM
*-------------------------------------------------------------------------
* WORK: - (ha \2==0 -> nem d0 a \1!) (\3: cycle!) (with iec test)
* memwritezpt d1: addr.w --> \1: data.b
*-------------------------------------------------------------------------
memwritezpt MACRO
move.b \1,(RAM,d1.l)
cmp.b #$01,d1
bls \@9$
next \3
\@9$
IFEQ \2
move.b \1,d0
ENDIF
IFD STAT
addq.l #\3,STAC
ENDIF
subq.w #\3,CYC
bra iec_set
ENDM
*-------------------------------------------------------------------------
* WORK: -
* push \1: data.b
*-------------------------------------------------------------------------
push MACRO
swap RSP
move.b \1,(RAM,RSP.w)
subq.b #1,RSP
swap RSP
ENDM
*-------------------------------------------------------------------------
* WORK: \1
* pop \1: data.b (output)
*-------------------------------------------------------------------------
pop MACRO
swap RSP
addq.b #1,RSP
move.b (RAM,RSP.w),\1
swap RSP
ENDM
*-------------------------------------------------------------------------
* WORK: \1 !!! utána újabb swap RSP kell !!!
* pop \1: data.b (output)
*-------------------------------------------------------------------------
popns MACRO
swap RSP
addq.b #1,RSP
move.b (RAM,RSP.w),\1
ENDM
*-------------------------------------------------------------------------
* WORK: d0
* push2 \1: data.w
*-------------------------------------------------------------------------
push2 MACRO
rol.w #8,\1
swap RSP
subq.b #2,RSP
move.w \1,1(RAM,RSP.w)
swap RSP
ENDM
*-------------------------------------------------------------------------
* WORK: \1 (16bit)
* pop2 \1: data.w (output)
*-------------------------------------------------------------------------
pop2 MACRO
swap RSP
move.w 1(RAM,RSP.w),\1
rol.w #8,\1
addq.b #2,RSP
swap RSP
ENDM
*-------------------------------------------------------------------------
* WORK: -
* pushrp - c+4 statust a verembe
*-------------------------------------------------------------------------
pushrp MACRO
makerp
move.w RA,d1
lsr.w #8,d1
push d1
ENDM
*-------------------------------------------------------------------------
* WORK: - push2 d1; pushrp
* pushstatus - menti a gép státuszát: d1-RPC + rp
*-------------------------------------------------------------------------
pushstatus MACRO
makerp
move.w RPC,d1
rol.w #8,d1
swap RSP
subq.b #3,RSP
move.w d1,2(RAM,RSP.w)
move.w RA,d1
lsr.w #8,d1
move.b d1,1(RAM,RSP.w)
swap RSP
ENDM
*-------------------------------------------------------------------------
* WORK: -
* poprp - verembõl c+4 statuszba
*-------------------------------------------------------------------------
poprp MACRO
move.b RA,d0
pop RA
lsl.w #8,RA
move.b d0,RA
makeccr
ENDM
*-------------------------------------------------------------------------
* WORK:
* resetdogfx
*-------------------------------------------------------------------------
resetdogfx MACRO
move.b #$80,_cureor
move.l #_modegfx,a0
swap RA
clr.w RA
move.b RA,_userblank
and.b #ORFLASH,RA
or.b #MODEINIT,RA
tst.l _opt_direct
beq \@1$
or.b #$80,RA
\@1$ move.l (a0,RA.w*4),DOGFX
swap RA
ENDM
*-------------------------------------------------------------------------
* WORK:
* updatedogfxns
*-------------------------------------------------------------------------
updatedogfxns MACRO
move.l #_modegfx,a0
move.l (a0,RA.w*4),DOGFX
swap RA
ENDM
*-------------------------------------------------------------------------
* WORK: d1
* reset7501
*-------------------------------------------------------------------------
reset7501 MACRO
bsr sidreset
bsr iec_reset
resetdogfx
move.b #$ff,keyread
move.w $fffc(HIRAM),d1
rol.w #8,d1
makepc
clr.l d0
clr.l d1
nextst
ENDM
*-------------------------------------------------------------------------
* WORK: d1
* irqhted
*-------------------------------------------------------------------------
irqhted MACRO
btst #B_IRQ,RA ; SEI?
bne \@1$
move.b (RPC)+,d0 ; fetch opcode
move.l (FETCH,d0.l*4),a0 ; next statement's address
move.l FETCH,actfetch ; save FetchTable
move.l #fetchtableirq,FETCH ; set special fetchtable
jmp (a0)
\@1$ bset #OLDIRQ,RP
ENDM
*-------------------------------------------------------------------------
* WORK: Itt kezeljük az irq elõtt utolsóként végrehajtott utasítás