Sunday, May 20, 2018

MESS is a mess

I had hoped to post some videos comparing the M6803 and HD6303 on the MESS MC-10 emulation.  That doesn't seem to be an option at the moment as MESS locks up the machine after a few minutes.  It turns out that the recent build is doing this even without any of my changes.  This may be an issue with the current Windows 10 update I'm running.  The MESS timing also appeared to be off, as the 6303 was running slower than the 6803.  That should never be the case.  I could see less of a speedup than originally expected, but it should never be slower running BASIC.

Friday, April 27, 2018

Patching the CoCo ROM, where to go from here.

There are several more patches I'm going to release.

The CHRGET/CHRGOT patch and changing the code that divides by 10 used for ASCII conversion are about ready to go.  They should speed up all programs somewhere between 2% and 4% if the results on the MC-10 are any indicator.  These could cause a few programs to act differently or even fail depending on what they do.  That's unlikely, but possible.  So the patch will be designed so it can be assembled with or without that code.

There is a 16x16 multiply that can be replaced.  This speeds up array indexing if I remember right.  The code should be easily ported from the MC-10.

There are a series of 6309 patches that can be easily implemented.  Screen scrolling and memory moves are the easiest to implement and the new code should fit over the old code in memory. 
A fast divide and faster multiply can be implemented.  The 6309 divide and larger multiply instructions are signed, so that will require a work around, but it's doable.  Those will probably offer the greatest improvement for the least work.  There are little patches that can go here and there, but those will require a lot of testing to be sure they don't break anything.  Many of these will even work on a CoCo 1 & 2 since they will fit in the original ROM space.  The fast multiply might even fit.

New square root code.  (SQR).  There wasn't enough space for this in the MC-10 ROM, but this will sit in RAM above ROM so it won't be an issue with the CoCo 3.  Most of the code has already been worked out on the MC-10, but there was one lingering issue.  The new code depends on a "magic" constant.  The existing one only works for double precision numbers and the appropriate number for the CoCo/MC-10 floating point format will have to be generated.  It may also impact precision.  *IF* I get this working, it should run about 20% faster.  This should drop Ahl's benchmark numbers down close to an IBM PC and SQR is also used in the fractal generator code I've been tinkering with.
This mod may take some time to work out.

Monday, April 23, 2018

Code for the higher resolution 3D Fedora Plot I posted a snapshot of on Facebook. This is the original Atari code followed by the changes to run on the CoCo 3.
100 SX=144:SY=56:SZ=64:CX=320:CY=192
110 C1=2.2*SY:C2=1.6*SY
120 DIM RR(CX)
130 FOR I=0 TO CX:RR(I)=CY:NEXT I
140 GRAPHICS 8+16:SETCOLOR 2,0,0:COLOR 1
150 CX=CX*0.5:CY=CY*0.46875:FX=SX/64:FZ=SZ/64
160 XF=4.71238905/SX
170 FOR ZI=64 TO -64 STEP -1
180   ZT=ZI*FX:ZS=ZT*ZT
190   XL=INT(SQR(SX*SX-ZS)+0.5)
200   ZX=ZI*FZ+CX:ZY=CY+ZI*FZ
210   FOR XI=0 TO XL
220     A=SIN(SQR(XI*XI+ZS)*XF)
230     Y1=ZY-A*(C1-C2*A*A)
240     X1=XI+ZX
250     IF RR(X1)>Y1 THEN RR(X1)=Y1:PLOT X1,Y1
260     X1=ZX-XI
270     IF RR(X1)>Y1 THEN RR(X1)=Y1:PLOT X1,Y1
280   NEXT XI
290 NEXT ZI

80 TIMER=0
90 POKE 65497,0
140 HSCREEN 2
250 IF RR(X1)>Y1 THEN RR(X1)=Y1:HSET(X1,Y1)
270 IF RR(X1)>Y1 THEN RR(X1)=Y1:HSET(X1,Y1)
300 PRINT"TIME",TIMER/60

Computer timing shows a 25.6% speed increase over the factory ROM.
Just remember this is only because the program uses a lot of multiplication.

0 TIMER=0:POKE65497,0
10 PMODE4,1:PCLS0:SCREEN1,1
20 DR=3.1415/180:DS=SIN(15*DR):DC=COS(15*DR)
30 FORR=5TO330STEP10
40 FORT=0TO360STEP10
50 X=R*COS(T*DR)*.25
60 Y=R*SIN(R*DR)*.25
70 Z=R*SIN(T*DR)*.25
80 XP=X+(DC*Z)
90 YP=Y+(DS*Z)
92 XP=128+XP
95 YP=80-YP
100 PSET(XP,YP,1)
110 NEXT:NEXT
115 T=TIMER/60
120 A$=INKEY$:IFA$=""THEN120
130 PRINT"TIME:",T

Sunday, April 22, 2018

Patching the CoCo ROM, patch #1

In honor of CoCofest, I give you patch #1.  This just patches the multiply and it only uses 6809 code.
Don't bother disassembling it, the source code will get posted once I patch a few more things.

Yeah, I can get away with patching the CoCo 3 ROM from BASIC on this one.  Other patches will have to be an executable.  ONLY FOR THE COCO 3!

1 POKE 65497,0
2 AD=VAL("&HFA0C")
10 FORI=0 TO 64:READ B$:A=VAL("&H"+B$)
11 POKE AD+I,A:NEXT

REM $BB02 JMP $FA0C
20 POKE VAL("&HBB02"),VAL("&H7E"):POKE VAL("&HBB03"),VAL("&HFA"):POKE VAL("&HBB04"),VAL("&H0C")


30 DATA 32,79,E7,60,96,60,3D,ED,63,E6,60,96,5E,3D,ED,61,E6,60,96,5D
40 DATA 3D,ED,65,E6,60,96,5F,3D,E3,62,ED,62,EC,65,E9,61,89,00,ED,60
50 DATA EC,63,D3,15,97,16,D7,63,EC,61,D9,14,99,13,DD,14,A6,60,89,00
60 DATA 97,13,32,67,39



Monday, April 16, 2018

Patching the CoCo ROM Part 8

The multiply code has been done since the 2nd day, but there's something odd going on.  I'm going to have to step through the ROM in a debugger to see what is going on.  Not sure if it's the wrong address for floating point registers or what.  Once that's fixed, I can enable the 2nd optimization (replacing /10 with * 1/10) and finish looking through the ROMs to see if the CHRGET & CHRGOT call patching can be automated or if a list of addresses or exclusions will be needed.
When completed, you should be able to LOADM and EXEC the patch.  That's it.  A version that works with the DOS command might be in the future, but it's not really necessary.

On another note... someone asked me if changing code that divides by a constant to multiplication by 1/constant causes it to run at a different speed on the original ROMs.  Once the initial divide calculation for 1/constant is made, the code should run the same speed as before with standard ROMs, but it will automatically be faster on a machine with an optimized ROM or with the patch I'm working on.  There's no reason not to make the change.

Wednesday, April 11, 2018

First CoCo fast multiply results

After much fiddling with the looped version of the multiply it still wasn't working and wasn't much smaller than the non-looped code, so I dumped it and finished the first version for the CoCo 3.
It still has a bug impacting accuracy, but it's close enough to give us an idea of how it will perform.  The CoCo 3 turned in a time of 45 seconds on Ahl's benchmark in high speed mode.