Tiny C64 (old school)

Post your FreeBASIC source, examples, tips and tricks here. Please don’t post code without including an explanation.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Post by D.J.Peters »

PRINT 1/3[ENTER]

after 20,000 debug steps the wrong result of floating point div 1/3 will be printed

i don't know how i should debug all this 20,000 CPU instructions :-(

Joshy
Last edited by D.J.Peters on Nov 12, 2009 3:43, edited 2 times in total.
srvaldez
Posts: 3379
Joined: Sep 25, 2005 21:54

Post by srvaldez »

thank you, keep us posted on your progress. :)
h4tt3n
Posts: 698
Joined: Oct 22, 2005 21:12
Location: Denmark

Post by h4tt3n »

D.J. this is really awesome. I'm speechless - how the heck did you figure out how to do something like this...

I really hope you will continue to develop this C64 emulator.

Edit after a few quick experiments: multiplication and the Sqr() function is somehow seriously flawed, although + and - seems fine.

Cheers, and good luck
h4tt3n
redcrab
Posts: 623
Joined: Feb 07, 2006 15:29
Location: France / Luxemburg
Contact:

Post by redcrab »

I'm really deeply impressed by your work !!

But I do not now C64 ... do you have the same for TI99/4A ;)

Hardware Architecture emulation , is not a easy task
Congrat !
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Post by D.J.Peters »

redcrab wrote:... do you have the same for TI99/4A ;)
Image
This emulator are for Win32 and Linux.

Joshy
Last edited by D.J.Peters on Nov 21, 2009 10:44, edited 1 time in total.
Dr_D
Posts: 2451
Joined: May 27, 2005 4:59
Contact:

Post by Dr_D »

D.J.Peters wrote:
redcrab wrote:... do you have the same for TI99/4A ;)
Image
This emulator are for Win32 and Linux.

Joshy
Wow! I remember playing around with one of those when I was a kid. I made it say curse-words though, and I never got to mess with it again. :(
Cherry
Posts: 358
Joined: Oct 23, 2007 12:06
Location: Austria
Contact:

Post by Cherry »

yes, a lot of divisions fail. Like "?1/2" - it prints something like "0.11".

but I LOVE you code, really.

btw - the window is a little bit small ->

Code: Select all

#Include "windows.bi"
#Include "fbgfx.bi" 

const scalar = 2

   ...

constructor OLdSchool
  dim as integer i,c
  dprint("OldSchool()")
  screenres 320+8*8,200+8*8,,8
  scope
    Dim hwnd As HWND
    ScreenControl(FB.GET_WINDOW_HANDLE, hwnd)
    MoveWindow(hwnd, 100, 100, (320+8*8)*scalar, (200+8*8)*scalar, TRUE)
  end scope
  for i=0 to 15
    read c:palette i,c
  next
  line (0,0)-(319+8*8,199+8*8),3,bf
  mem=new MEMORY
  cpu=new CPU6510(mem)
end constructor
greetings, Cherry
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Post by D.J.Peters »

Cherry@
Yes it's a short window for a short test :-)

in an real 64 emulator with VIC chip emulation
the VIC chip has the whole control of the CPU bus
only every ~8th pixel output from VIC the CPU get
back the data bus (and some CPU instructions needs 2 or more cycles)

that meas if the VIC chip plots out one scanline 320pixels + border
the CPU can handle only 64 cycles on PAL and 65 on NTSC systems

And for every first text scanline of a row (every 8th scanline)
the CPU get lesser cycles this lines are named bad lines :lol:
(the program CPU cycles are eaten for addressing a char bitmap from font)

that are not all trouble the VIC chip emualtion it will eaten more
cycles to address the harware sprites too

least but not last the VIC chip can generate on any scanline an rasterinterrupt
with this feature you can split the screen in text and gfx mode together in one frame!
or you can change the border color more than once per frame
and you can clone the 8 sprites to get more of them in one frame

if you will write a VIC chip emu than you must create 50/60 PAL/NTSC frames per second and you must scale it to the larger window size.

i know how all this works but there are some good C64 emus aviable
and i'm working hard on my main project FreeSpeedRacer

but it was funy to get a self created virtual CPU running

bla bla bla :-)

Joshy
Last edited by D.J.Peters on Mar 08, 2008 2:41, edited 1 time in total.
Merick
Posts: 1038
Joined: May 28, 2007 1:52

Post by Merick »

Dr_D wrote:
D.J.Peters wrote:
redcrab wrote:... do you have the same for TI99/4A ;)
Image
This emulator are for Win32 and Linux.

Joshy
Wow! I remember playing around with one of those when I was a kid. I made it say curse-words though, and I never got to mess with it again. :(
heh, I never made it say curse words, but I spent hours playing Parsec and Tunnels of Doom
redcrab
Posts: 623
Joined: Feb 07, 2006 15:29
Location: France / Luxemburg
Contact:

Post by redcrab »

D.J.Peters wrote:
redcrab wrote:... do you have the same for TI99/4A ;)
Image
This emulator are for Win32 and Linux.

Joshy
Whoot ... top kewl...
Voltage
Posts: 110
Joined: Nov 19, 2005 7:36
Location: Sydney, Australia
Contact:

Post by Voltage »

Hey Joshy.

I found this:

"If the D flag is set, all ADC and SBC operations will be BCD-adjusted afterwards, i.e. $09+$02 won’t be $0B, but $11, since 9+2=11. "

Your ADC / SBC routines don't take decimal mode into consideration.

The flags seem ok to me... although I haven't tested the signed adc/sbc yet.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Post by D.J.Peters »

hello Voltage
looks like you found it
it's posible that float math from C64 BASIC used BCD math.

fix it if you can.

thanx Joshy
E.K.Virtanen
Posts: 785
Joined: May 28, 2005 9:19
Location: Finland

Post by E.K.Virtanen »

Impressive one. No clue how to do better than this one.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Post by D.J.Peters »

hello Voltage

i added this line

if lpCPU->F.d=1 then beep ' !!! BCD mode

to instructions ADC,SBC and SED

but i don't get any beep
i mean the KERNAL or the BASIC ROM will never set the BCD flag

i tryed PRINT 1/3 but the BCD flag is all times cleared

can be an error in my ROM's i don't know :-(

Joshy
kiyotewolf
Posts: 1009
Joined: Oct 11, 2008 7:42
Location: ABQ, NM
Contact:

Post by kiyotewolf »

PRINT 1*1
gives..

3.66210938E-04


I think the first step, is to try to do a battery of tests, to see if we can figure out how it's doing multiplication and division, using whatever new operator(-eration) it's doing instead.

That way, maybe we can help target it.

PRINT 3/1
gives..

3



I will go through this, and scrutinize what I can, although the exhorberant amount of pointer redirection is going to make my head spin.

I will put on my magic reading glasses and try to divine what I can even though I won't be able to read all of it.



~Kiyote!
Post Reply