-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuNBScreen.pas
1290 lines (1134 loc) · 32.3 KB
/
uNBScreen.pas
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
{
Grundy NewBrain Emulator Pro Made by Despsoft
Copyright (c) 2004, Despoinidis Chris
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON A
NY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
}
unit uNBScreen;
interface
Uses uNBTypes,DXDraws,uNBStream,graphics,classes;
Const ScreenYOffset=2;
ScreenXOffset=2;
Type
TNBScreen=Class
private
Char8: Boolean;
FPSTick: Cardinal;
GraphExists: Boolean;
Grst: TNbStream;
lengx, lengy: integer;
ParamPg: Integer;
ParamOffset: Word;
ParamGrPage: Byte;
ParamGrOffset: Word;
ISCpmV: Boolean;
Startofgraph: Integer;
GrPage: Byte;
EndOfText: Integer;
HasText: Boolean;
Printedlines: Integer;
function GetNextByte(var p, Offset: Integer): Byte;
function GetDEP: byte;
function GetEL: byte;
function GetExcess: Byte;
function GetEXFlags: byte;
function GetFlags: byte;
function GetFRM: byte;
function GetinpB: byte;
function GetinpC: Byte;
function GetLL: byte;
function GetLN: byte;
function GetPLLEN: Byte;
function GetPZLEN: Byte;
function GetTvMode: Byte;
function GetTVOverHead: Integer;
function GetVideoAddr: TPair;
function GetVideoMem: TPair;
function GraphWidth: Word;
function lastGraph: TPair;
function startgraph: Tpair;
function GetAVideoTop: TPair;
function GetTV4: Byte;
function GetVideoBase: TPair;
function GetVIDEOTOP: TPair;
function IsPaged: Boolean;
function GetTV0: Byte;
function GetSlotn(w: Word): Integer;
procedure dopaint(Sender: TObject);
public
horzmult:Integer;
vertmult:Integer;
EMUScrheight:integer; //variable
EMUScrWidth:integer;
FPS: Integer;
Lastfps: Integer;
nbs:TNBStreamManipulation;
pgnbs:TNBPGStreamManipulation;
Newscr: TDXDraw;
ShowFps: Boolean;
LedText: string;
VideoAddrReg: Word;
TVModeReg: Byte;
VIdeoPage: Byte;
WhiteColor: TColor;
BlackColor: TColor;
Reverse:Boolean;
Dev33Page: Integer;
VIDEOMSB: Integer;
CpTm:Cardinal;
CkTm:Cardinal;
Constructor Create;
function GetGraphStrm: TNBStream;
function Graphlines: Word;
procedure Clearscr;
procedure paintGraph(ISDev33:Boolean=false);
function PaintVideo: Boolean;
procedure PaintLetter(Const cx,cy:Integer;Ch:Byte;const dopaint:boolean=false);
procedure PaintLeds(txt:String);
procedure PaintDebug;
function GetParamed(Offs:word): Byte;
function ValidGraph: Boolean;
procedure CaptureToDisk;
property DEP: byte read GetDEP;
property EL: byte read GetEL;
property Excess: Byte read GetExcess;
property EXFlags: byte read GetEXFlags;
property Flags: byte read GetFlags;
property FRM: byte read GetFRM;
property inpB: byte read GetinpB;
property inpC: Byte read GetinpC;
property LL: byte read GetLL;
property LN: byte read GetLN;
property PLLEN: Byte read GetPLLEN;
property PZLEN: Byte read GetPZLEN;
property TVMode: Byte read GetTvMode;
property VideoAddr: TPair read GetVideoAddr;
property VideoMem: TPair read GetVideoMem;
property AVideoTop: TPair read GetAVideoTop;
property TV4: Byte read GetTV4;
property VideoBase: TPair read GetVideoBase;
property VIDEOTOP: TPair read GetVIDEOTOP;
property TV0: Byte read GetTV0;
End;
procedure LoadCharSet(fname:string);
Var NBScreen:TNbScreen;
CharArr:Array[0..2560] of byte; //charset array
implementation
Uses z80baseclass,Sysutils,forms,uNBMemory,frmNewdebug,new,
jcllogic,windows,uNBCop,uNBIO,controls;
//loads the charset from the disk
procedure LoadCharSet(fname:string);
Var f:File Of byte;
i:Integer;
pth:String;
begin
pth:=Extractfilepath(application.exename);
if FileExists(pth+fname) then
Begin
system.Assign(f,pth+fname);
reset(f);
For i:=0 to 2560 do
BEgin
read(f,CharArr[i]);
End;
system.Close(f);
End;
end;
constructor TNBScreen.Create;
begin
// Frame:=nil;
WhiteColor:=clWhite;
BlackColor:=clBlack;
nbs:=TNBStreamManipulation.Create;
pgnbs:=TNBPGStreamManipulation.Create;
horzmult:=2;
vertmult:=2;
EMUScrheight:=250; //variable
EMUScrWidth:=640;
end;
procedure TNBScreen.ClearScr;
var i:Integer;
Begin
for i:=videoMem.w to videoMem.w+eL*DEP do
nbmem.rom[i]:=32;
End;
function TNBScreen.GetDEP: byte;
begin
//tvmode reg is set by out at port 12
// Bit 0 is Reverse video
// Bit 1 is full character Set
// Bit 2 is narrow screen
// Bit 3 is 30 lines display
// Bit 6 is 40 lines width if 0 , 80 lines if 1
If testbit(TVModeReg,3) then
result:=30
else
result:=26;
end;
function TNBScreen.GetEL: byte;
begin
If testbit(TVModeReg,6) then
result:=128
else
result:=64;
end;
function TNBScreen.GetExcess: Byte;
begin
result:=24; //fixed for model AD
exit;
if not ispaged then
Result := nbmem.ROM[$0c]
else
result:=24;
end;
function TNBScreen.GetEXFlags: byte;
begin
if not ispaged then
Result := nbmem.ROM[videoaddr.w+8]
Else
result:=GetParamed(8);
end;
function TNBScreen.GetFlags: byte;
begin
if not ispaged then
Result := nbmem.ROM[videoaddr.w+7]
else
result:=GetParamed(7);
end;
function TNBScreen.GetFRM: byte; //Not Used
begin
result:=0;
exit;
if IsCPMv then
Result:=0
Else
if not ispaged then
Result := nbmem.ROM[videoaddr.w+10]
Else
Begin
result:=GetParamed(10);
Result:=0;
//it is valid but we have the right
//start address anyway so we dont need frm
End;
end;
//Get the stream for device 11=Graphics
function TNBScreen.GetGraphStrm: TNBStream;
begin
result:=nbs.FindStrmByMem(VideoAddr);
if nbs.found then
Begin
nbs.found:=false;
result:=nbs.FindStrmForGraph(11,result.PortNo);
End;
end;
function TNBScreen.GetinpB: byte;
begin
if not ispaged then
Result := nbmem.ROM[videoaddr.w+12]
else
result:=GetParamed(12);
end;
function TNBScreen.GetinpC: Byte;
begin
if not ispaged then
Result := nbmem.ROM[videoaddr.w+13]
Else
result:=GetParamed(13);
end;
function TNBScreen.GetLL: byte;
begin
If testbit(TVModeReg,6) then
result:=80
else
result:=40;
exit;
if IsCPMv then
Result:=80
Else
if not ispaged then
Result := nbmem.ROM[videoaddr.w+5]
else
result:=GetParamed(5);
end;
function TNBScreen.GetLN: byte;
begin
If testbit(TVModeReg,6) then
result:=80
else
result:=40;
exit;
if IsCPMv then
Result:=80
else
if not ispaged then
Result := nbmem.ROM[videoaddr.w+9]
Else
result:=GetParamed(9);
end;
function TNBScreen.GetPLLEN: Byte;
begin
//Chars per line 40 or 80
Result := nbmem.ROM[$1b];
end;
function TNBScreen.GetPZLEN: Byte;
begin
Result := nbmem.ROM[$1d]; //10 for 40 chars
end; //17 for 80 chars
function TNBScreen.GetTvMode: Byte;
begin
if IsCPMv then
Result:=1
Else
if not ispaged then
Result:=nbmem.rom[VideoAddr.w+1] and $f
Else
result:=GetParamed(1) and $f;
end;
function TNBScreen.GetTVOverHead: Integer; //Not Used
Begin
if IsCPMv then
Result:=0
else
if Not ispaged then
Result:=nbmem.Rom[videoAddr.w]+5
Else
result:=1;
End;
function TNBScreen.GetVideoAddr: TPair;
begin
if not IsCpmV then
Begin
Result.h := nbmem.rom[$5d];
Result.l := nbmem.rom[$5c];
End
Else
Result.w:=0;
end;
function TNBScreen.GetVideoMem: TPair;
begin
// Result.w:=videoAddr.w+GetTVOverHead //actual address
If testbit(TVModeReg,6) then
Result.w:=videoAddrreg+4 //actual address
Else
Result.w:=videoAddrreg+2; //actual address
end;
function TNBScreen.GraphLines: Word;
begin
result:=0;
If not ispaged then
result:=nbmem.rom[GRst.Memory.w+28]
Else
if nbmem.chipexists(ParamGRPage) then
result:=nbmem.nbPages[ParamGRPage]^.Memory[ParamGROffset+34];//28
end;
function TNBScreen.GraphWidth: Word;
begin
result:=0;
If Not ispaged then
result:=nbmem.rom[GRst.Memory.w+25]
Else
if nbmem.chipexists(ParamGRPage) then
result:=nbmem.nbPages[ParamGRPage]^.Memory[ParamGROffset+31]; //25
end;
function TNBScreen.LastGraph: TPair; //Not Used
begin
result.l:=nbmem.rom[GRst.Memory.w+44];
result.h:=nbmem.rom[GRst.Memory.w+45];
result.w:= result.w-1;
end;
//Paint the debug information on Newdebug form
procedure TNBScreen.PaintDebug;
Var
h,i:Integer;
s:String;
Col1,Col2,Col3,col4:Integer;
Procedure PaintFlags;
Var af:TPair;
f:Byte;
s:String;
i:Integer;
Begin
af.w:=z80_get_reg(Z80_REG_AF);
f:=af.l;
s:='szxnxpnc';
for i:=0 to 7 do
if TestBit(f,Byte(i)) then
s[8-i]:=Uppercase(s[8-i])[1]
else
s[8-i]:=Lowercase(s[8-i])[1];
NewDebug.debugscr.Surface.Canvas.
TextOut(Col3,1*h,'FL : '+s);
End;
Procedure PAintSP;
var sp:TPair;
i:Integer;
Begin
sp.w:=z80_get_reg(Z80_REG_SP);
i:=2;
with NewDebug.debugscr.Surface.Canvas do
begin
repeat
s:=Format('%s : %s',[inttohex(sp.w,4),Inttohex(nbmem.rom[sp.w],4)]);
sp.w:=sp.w-2;
inc(i);
TextOut(Col4,i*h,s);
if i>15 then break;
until false;
End;
End;
Begin
Col1:=10;
Col2:=140;
Col3:=320;
col4:=450;
if not NewDebug.debugscr.CanDraw then exit;
NewDebug.debugscr.Surface.Fill(0);
NewDebug.debugscr.Surface.Lock();
with NewDebug.debugscr.Surface.Canvas do
begin
Brush.Style := bsClear;
Font.Name:='Courier New';
Font.Color := clWhite;
Font.Size := 8;
h:=10;
if fNewBrain.Suspended then
s:='Suspended'
else
s:='Running';
Textout(Col1, 0, DateTimeToStr(Now)+' Engine is '+s);
TextOut(Col1,1*h,'PC : '+inttohex(z80_get_reg(Z80_REG_PC),4));
TextOut(Col1,2*h,'AF : '+inttohex(z80_get_reg(Z80_REG_AF),4));
TextOut(Col1,3*h,'HL : '+inttohex(z80_get_reg(Z80_REG_HL),4)+'('+Inttostr(nbmem.rom[z80_get_reg(Z80_REG_HL)])+')');
TextOut(Col1,4*h,'DE : '+inttohex(z80_get_reg(Z80_REG_DE),4));
TextOut(Col1,5*h,'BC : '+inttohex(z80_get_reg(Z80_REG_BC),4));
TextOut(Col1,6*h,'IX : '+inttohex(z80_get_reg(Z80_REG_IX),4));
TextOut(Col1,7*h,'IY : '+inttohex(z80_get_reg(Z80_REG_IY),4));
TextOut(Col1,8*h,'IM : '+inttohex(z80_get_reg(Z80_REG_IM),4));
TextOut(Col1,9*h,'IR : '+inttohex(z80_get_reg(Z80_REG_IR),4));
TextOut(Col1,10*h,'IF1 : '+inttohex(z80_get_reg(Z80_REG_IFF1),4));
TextOut(Col1,11*h,'IF2 : '+inttohex(z80_get_reg(Z80_REG_IFF2),4));
TextOut(Col1,12*h,'SP : '+inttohex(z80_get_reg(Z80_REG_SP),4));
TextOut(Col1,13*h,'IRQV : '+inttohex(z80_get_reg(Z80_REG_IRQVector),4));
TextOut(Col1,14*h,'IRQL : '+inttohex(z80_get_reg(Z80_REG_IRQLine),4));
TextOut(Col1,15*h,'Halt : '+inttohex(z80_get_reg(Z80_REG_Halted),4));
PaintFlags;
TextOut(Col1,18*h,'COPCTL: '+getbinaryfrombyte(nbmem.ROM[$3b]));
TextOut(Col1,19*h,'COPST : '+getbinaryfrombyte(nbmem.ROM[$3c]));
TextOut(Col1,20*h,'ENREG1: '+getbinaryfrombyte(nbmem.ROM[$24]));
TextOut(Col1,21*h,'IOPUC : '+inttohex(nbmem.ROM[$25],2));
s:=inttohex(nbmem.ROM[$1f],2)+inttohex(nbmem.ROM[$1e],2);
TextOut(Col1,22*h,'SAVE1 : '+s);
TextOut(Col1,23*h,'EL : '+inttohex(EL,4));
TextOut(Col1,24*h,'LL : '+inttohex(LL,4));
TextOut(Col1,25*h,'LN : '+inttohex(LN,4));
TextOut(Col1,26*h,'DEP : '+inttohex(DEP,4));
TextOut(Col1,27*h,'FRM : '+inttohex(FRM,4));
TextOut(Col1,28*h,'FLAGS : '+getbinaryfrombyte(FLAGS));
TextOut(Col1,29*h,'EXFLAG: '+getbinaryfrombyte(EXFLAGS));
TextOut(Col1,30*h,'INPB : '+inttohex(inpb,4));
TextOut(Col1,31*h,'INPC : '+inttohex(inpc,4));
s:=inttohex(nbmem.ROM[$5b],2)+inttohex(nbmem.ROM[$5a],2);
TextOut(Col1,32*h,'TVCUR : '+s);
s:=inttohex(nbmem.ROM[$5d],2)+inttohex(nbmem.ROM[$5c],2);
TextOut(Col1,33*h,'TVRAM : '+s);
s:=inttohex(nbmem.ROM[$05],2)+inttohex(nbmem.ROM[$04],2);
TextOut(Col1,34*h,'B3PRM : '+s);
s:=inttohex(nbmem.ROM[$38],2)+inttohex(nbmem.ROM[$3A],2)+inttohex(nbmem.ROM[$39],2);
TextOut(Col1,35*h,'RST56 : '+s);
s:=inttohex(nbmem.ROM[$2d],2)+inttohex(nbmem.ROM[$2c],2);
TextOut(Col1,36*h,'GSPR : '+s);
s:=inttohex(nbmem.ROM[$07],2)+inttohex(nbmem.ROM[$06],2);
TextOut(Col1,37*h,'B4 : '+s);
s:=inttohex(nbmem.ROM[$57],2)+inttohex(nbmem.ROM[$56],2);
TextOut(Col1,38*h,'STRTAB: '+s);
s:=inttohex(nbmem.ROM[$65],2)+inttohex(nbmem.ROM[$64],2);
TextOut(Col1,39*h,'STRTOP: '+s);
TextOut(Col1,40*h,'ENREG2: '+getbinaryfrombyte(nbmem.ROM[$B6]));
if Breaked or stopped then
TextOut(Col1,41*h,'Breakpoint reached');
TextOut(Col2,30*h,'TVMode: '+inttostr(TVMode));
s:=inttohex(nbmem.ROM[120],2)+inttohex(nbmem.ROM[119],2);
TextOut(Col2,31*h,'CHRROM: '+s);
s:=inttohex(nbmem.ROM[85],2)+inttohex(nbmem.ROM[84],2)
+inttohex(nbmem.ROM[83],2)+inttohex(nbmem.ROM[82],2);
TextOut(Col2,1*h,'CL/CK : '+s);
s:=inttohex(nbmem.ROM[107],2)+inttohex(nbmem.ROM[106],2)
+inttohex(nbmem.ROM[105],2);
TextOut(Col2,2*h,'FICLK : '+s);
s:=inttohex(nbmem.ROM[21],2)+inttohex(nbmem.ROM[20],2);
TextOut(Col2,3*h,'SAVE2 : '+s);
s:=inttohex(nbmem.ROM[23],2)+inttohex(nbmem.ROM[22],2);
TextOut(Col2,4*h,'SAVE3 : '+s);
s:=inttohex(nbmem.ROM[$3D],2);
TextOut(Col2,6*h,'COPBF : '+s);
s:=inttohex(nbmem.ROM[$51],2)+inttohex(nbmem.ROM[$50],2);
TextOut(Col2,7*h,'CHSUM : '+s);
TextOut(Col2,37*h,'TV0 : '+inttostr(nbmem.rom[13]));
TextOut(Col2,38*h,'TV2 : '+getbinaryfrombyte(nbmem.rom[14]));
TextOut(Col2,39*h,'TV1 : '+inttostr(nbmem.rom[15]));
TextOut(Col3,39*h,'TV4 : '+inttostr(TV4));
For i:=0 to 7 do
if nbmem.mainslots[i]<>nil then
TextOut(Col2,(10+i)*h,'M/S '+inttostr(i)+' : '+Inttostr(nbmem.mainslots[i].Page)+'.'+nbmem.mainslots[i].Name)
Else
TextOut(Col2,(10+i)*h,'M/S '+inttostr(i)+' : 000.N/A');
If nbmem.AltSet then
TextOut(Col2,19*h,'ALTN Set ')
Else
TextOut(Col2,19*h,'MAIN Set ');
For i:=0 to 7 do
if nbmem.Altslots[i]<>nil then
TextOut(Col2,(21+i)*h,'A/S '+inttostr(i)+' : '+Inttostr(nbmem.altslots[i].Page)+'.'+nbmem.Altslots[i].Name)
Else
TextOut(Col2,(21+i)*h,'A/S '+inttostr(i)+' : 0.N/A');
TextOut(Col3,4*h,'VTop : '+inttostr(Videotop.w));
TextOut(Col3,5*h,'VBase : '+inttostr(VideoBase.w));
TextOut(Col3,6*h,'AVtop : '+inttostr(AVideotop.w));
TextOut(Col3,7*h,'DiscB : '+inttostr(nbmem.rom[$7a]*256+nbmem.rom[$79]));
TextOut(Col3,8*h,'STR11 : '+inttostr(nbmem.rom[$76]));
TextOut(Col3,10*h,'S0 : '+inttostr(GetSlotn(nbmem.rom[$8c]*256+nbmem.rom[$8b])));
TextOut(Col3,11*h,'S1 : '+inttostr(GetSlotn(nbmem.rom[$8e]*256+nbmem.rom[$8d])));
TextOut(Col3,12*h,'S2 : '+inttostr(GetSlotn(nbmem.rom[$90]*256+nbmem.rom[$8f])));
TextOut(Col3,13*h,'S3 : '+inttostr(GetSlotn(nbmem.rom[$92]*256+nbmem.rom[$91])));
TextOut(Col3,14*h,'S4 : '+inttostr(GetSlotn(nbmem.rom[$94]*256+nbmem.rom[$93])));
TextOut(Col3,15*h,'S5 : '+inttostr(GetSlotn(nbmem.rom[$96]*256+nbmem.rom[$95])));
TextOut(Col3,16*h,'S6 : '+inttostr(GetSlotn(nbmem.rom[$98]*256+nbmem.rom[$97])));
TextOut(Col3,17*h,'S7 : '+inttostr(GetSlotn(nbmem.rom[$9a]*256+nbmem.rom[$99])));
if pclist<>nil then
Begin
For i:=pclist.count-1 downto 0 do
Begin
TextOut(Col3,(19+(pclist.count-i))*h,'PC-'+inttoStr(i)+' : '+inttoHex(Integer(PClist[i]),4));
if pclist.count-i>10 then break;
End;
For i:=splist.count-1 downto 0 do
Begin
TextOut(Col4,(19+(splist.count-i))*h,'sp-'+inttoStr(i)+' : '+inttoHex(Integer(splist[i]),4));
if splist.count-i>10 then break;
End;
PaintSp;
End;
try
newdebug.PaintListing;
Except
End;
Release; { Indispensability }
end;
NewDebug.debugscr.Surface.unLock;
NewDebug.DebugScr.Flip;
End;
//returns the bank slot that this address is
Function TNBScreen.GetSlotn(w:Word):Integer;
Var {sl,}pg:word;
//t:Tpair;
Begin
// sl:=w and $E000;
pg:=w And $ff;
//t.w:=pg;
Result:=pg;
End;
//Paint the graphics screen if there is one
procedure TNBScreen.paintGraph(ISDev33:Boolean=false);
Var i,j:Integer;
x,y:Integer;
lengx,lengy:integer;
addr:Integer;
nocx:integer;
nocy:integer;
ch:Byte;
Procedure DrawPixel(const x1,y1:integer; DoSet:Boolean);
var clr:TColor;
nx,ny:Integer;
i,j:Integer;
Begin
if reverse then doset:=not doset;
if doset then clr:=WhiteColor else clr:=blackColor;
nx:=ScreenXOffset+x1*horzmult;
ny:=ScreenYOffset+(startofgraph+y1)*vertmult;
for i:=0 to horzmult-1 do
for j:=0 to vertmult-1 do
newscr.Surface.Pixel[nx+i,(ny+j)]:=clr;
//frame.plot(nx+i,EMUSCRHeight-(ny+j),clr);
End;
var grp:Integer;
narrow:boolean;
ident:Integer;
begin
GraphExists:=false;
If not ValidGraph then exit;
GraphExists:=true;
If printedlines>=250 then exit;//max lines
lengx:=8; //8 bit
lengy:=1; //1 byte
// if not HasText then
// addr:=startGraph.w;
nocx:=GraphWidth; //280 bytes
nocy:=GraphLines;
if nocx=0 then
Begin
GraphExists:=false;
Exit;
End;
addr:=EndOftext;
grpage:=dev33page;//nbmem.lastpage;
nocy:=nocy+10-(nocy mod 10); //multiple of 10 lines always
if nocy>249 then nocy:=249;
// ODS(Format('Start Graph Video=%4x , Page=%d',[addr,grpage]));
reverse:= testbit(tvmodereg,0);
grp:=grpage;
narrow:=(nocx=32) or (nocx=64);
if narrow then
Begin
Ident:=nocx div 8;
addr:=addr+ident;
nocx:=nocx+ident;
End
else
ident:=0;
//addr:=addr+1;
if addr>=$ffff then exit;
{ if IsPaged and (addr>=$2000) then
Begin
//todo:Find this somehow
addr:=addr-$2000;
grp:=grp-1;
if grp<0 then exit;
End;}
for i:=0 to nocy-1 do //count lines
Begin
for j:=0 to nocx-1 do //count column bytes
Begin
If narrow and (j<ident) then
continue;
for y:=0 to lengy-1 do //enlarge pixel y
Begin
if IsPaged then
ch:=GetNextByte(grp,addr)
Else
Begin
ch:=nbmem.Rom[addr];
inc(addr);
end;
for x:=Lengx-1 downto 0 do //enlarge pixel x
Drawpixel(j*8+x,(i*1)+y, TestBit(ch,Byte(x)) );
End; //for y bit count
End; //for j
printedlines:=printedlines+1;
If printedlines>=250 then break;//max lines
End;//for i
// ODS(Format('End Video=%4x , Page=%d',[addr,grp]));
end;
//paint the 16 char vfd
procedure TNBScreen.PaintLeds(txt:String);
begin
ledtext:=copy(txt,1,16);
Fnewbrain.SetLed(nil);
end;
//Paint a letter(ch) on screen at position cx,cy
procedure TNBScreen.PaintLetter(Const cx,cy:Integer;Ch:Byte;const
dopaint:boolean=false);
Var
x,y:Integer;
addr:Integer;
charb:array[0..9] of byte;
Procedure getchar;
var i:Integer;
Begin
for i:=0 to 7 do
charb[i]:=ReverseBits(Chararr[addr+i*256]);
charb[8]:=0;
charb[9]:=0;
//two bottom lines
if ((ch>31) and (ch<128)) or (ch>159) then
Begin
if charb[0] and 128=128 then
Begin
charb[0]:=charb[0] and $7f; //clear bit 8
charb[8]:=charb[0];
charb[0]:=0;
End;
if charb[1] and 128=128 then
Begin
charb[1]:=charb[1] and $7f; //clear bit 8
charb[9]:=charb[1];
charb[1]:=0;
End;
End
else
charb[8]:=charb[7];
if reverse then
Begin
for i:=0 to 9 do
charb[i]:=Charb[i] xor $ff;
End;
End;
Procedure getchar8;
var i:Integer;
Begin
for i:=0 to lengy-1 do
charb[i]:=ReverseBits(Chararr[addr+i*256]);
if reverse then
Begin
for i:=0 to lengy-1 do
charb[i]:=Charb[i] xor $ff;
End;
End;
Function GetRomForChar(ch:byte):Integer;
Begin
result:=-1;
reverse:=false;
Case TVMode of
0,4:Begin //ctrl W-D set1
if ch>127 then
ch:=ch-128
else
reverse:=true;
result:=ch;
End;
1,5:Begin //ctrl W-A set1 reversed
if ch>127 then
Begin
ch:=ch-128;
reverse:=true;
End;
result:=ch;
End;
2,6:result:=ch; //Ctrl W-B set2
3,7:Begin //Ctrl W-C set2 reversed
result:=ch;
reverse:=true;
End;
8,12:Begin
if ch>127 then
BEgin
ch:=ch-128;
reverse:=true;
End;
result:=ch; // Ctrl W-H Set 3
End;
9,13:Begin
if ch>127 then
BEgin
ch:=ch-128;
End
else
reverse:=true;
result:=ch; // Ctrl W-I Set 3 reversed
End;
10,14:Begin
result:=ch; // Ctrl W-J Set 4
End;
11,15:Begin
result:=ch; // Ctrl W-k Set 4 reversed
reverse:=true;
End;
end;
End;
Procedure DrawPixel(const x,y:integer;const DoSet:Boolean);
var clr:TColor;
nx,ny:Integer;
i,j:Integer;
Begin
if doset then clr:=WhiteColor else clr:=blackColor;
nx:=ScreenXOffset+x*horzmult;
ny:=ScreenYOffset+y*vertmult;
for i:=0 to horzmult-1 do
for j:=0 to vertmult-1 do
newscr.Surface.Pixel[nx+i,(ny+j)]:=clr;
// frame.plot(nx+i,EMUSCRHeight-(ny+j),clr);
End;
Function GetRomCh(Ch:Byte):Integer;
Begin
reverse:= testbit(tvmodereg,0);
if not testbit(tvmodereg,1) then
Begin
if ch>127 then
Begin
ch:=ch-128;
reverse:=not reverse;
End;
End;
Result:=ch;
End;
begin
addr:=GetRomCh(ch);
if addr=-1 then exit;
getchar8; //get the char pattern to charb 10 byte array
for y:=0 to lengy-1 do
for x:=0 to lengx-1 do
DrawPixel(cx*lengx+x,cy*lengy+y,TestBit(charb[y],Byte(x)));
reverse:= testbit(tvmodereg,0);
end;
//get the page no and offset in screen buffer and return the screen byte
Function TNBScreen.GetNextByte(var p:integer;var Offset:Integer):Byte;
Procedure NextPage;
Begin
//Valid pages are only the 1st 4 rams
//104,105,106,107
//1st it gives the largest possible page
//then the smaller one it goes backwards
p:=p-1;
if p<104 then //shouldn't be here
p:=107;
//TODO: Find Next Page From a table
End;
Begin
if offset>=$2000 then
Begin
NextPage;
// ODS(Format('Change Video=%4x , Page=%d',[Offset,p]));
Offset:=Offset-$2000;
if offset>=$2000 then //max screen bytes are 20000 is 2.4 banks
Begin
NextPage;
// ODS(Format('Change Video=%4x , Page=%d',[Offset,p]));
Offset:=Offset-$2000;
End;
End;
Result:=nbmem.GetDirectMem(p,Offset);
inc(Offset);
End;
//Paint the video screen text
function TNBScreen.PaintVideo: Boolean;
var x,y,nender:Integer;
nValue:Byte;
s:String;
Visy:Integer;
FormOffst:Integer;
Procedure CheckScreen;
Begin
Fnewbrain.ClientWidth:=2*(fnewbrain.newscr.Left-fnewbrain.Panel6.Left)+ HorzMult*LL*8 ;//+ScreenXOffset*2;
FormOffst:= fnewbrain.panel1.Height+fnewbrain.panel2.Height+fnewbrain.StatusBar1.Height; //48;// = led+Statusbar+4 bytes =25+19+4
EMUScrheight:=520; //should never change cause in 8x8 we show 30 lines not 25
fnewbrain.clientheight:=2*(fnewbrain.newscr.top)+FormOffst+250*2+8;//+ScreenYOffset*2;//4 bytes around the real screen
End;
Function TextVideo:Boolean;
var r:TPair;
Begin
if not ispaged then
result:=true
else
Begin
r.w:=videoaddr.w;
result:=pgnbs.GetVideoNoByAddress(r)<>-1;
End;
HasText:=Result;
End;
var
brked:boolean;
v1,v2:Byte;
v3,v4:Byte;
vp:Integer;
v,ofs:Integer;
IsDev33:Boolean;
nStart:Integer;
begin
Result:=false;
Printedlines:=0;
if not nbio.tvenabled then exit;
try
if not newscr.candraw or (el=0) then exit;
if (el<20) or (el>128) or (el=frm) then
Begin
FPS:=1;
exit;
End
else Inc(fps);
lengx:=8; //8x10 chars
if el=128 then
horzmult:=1
else
horzmult:=2;
if not TEstBit(TVModeReg,3) then
Begin
lengy:=10; //8x10 chars
if char8 then
LoadCharset('CharSet2.chr');
char8:=false;
End
else
Begin
lengy:=8; //8x8
if not char8 then
LoadCharset('CharSet4.chr');
Char8:=true;
End;