6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Apr 27, 2024 11:03 pm

All times are UTC




Post new topic Reply to topic  [ 30 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: Thu Jan 15, 2009 9:47 pm 
Offline
User avatar

Joined: Sun Feb 13, 2005 9:58 am
Posts: 85
thank you all for your hints, i found and fix the real problem.

first of all my wrong cast wasn't the real problem, because of other cast that make an implicit correction.

the main problem is that the fopen in the save function miss the 'b' option, so when you try to save a block of memory, 0x0d is extended in cr+lf, corrupting the memory block.

infact, if you try to join the two roms in one by hand, the emulation works fine.

a big thanx to BigEd for another fix.

i just tryed to compile and use the original apple1 figforth and it seems work fine, but i dont complete the i/o routines till now.

i'm not sure if lib6502 is a good (accurate) emulation library, but in my opinion can be a good start point for who like to develop 6502 code, it's simple and easy to use.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Jan 16, 2009 1:49 am 
Offline

Joined: Mon Dec 23, 2002 8:47 pm
Posts: 70
I've used Marat Fayzullin's M6502 on a bunch of my projects (in the form of M65C02, a hack I made on it which supports up as far as the 65SC02 opcodes). Might find it if you can dig up an old version of Dapple (I think it was in the 1.0x time I replaced it with Dapple Core), or it's prolly still on the sf project page with Dapple...


Top
 Profile  
Reply with quote  
PostPosted: Sun Mar 01, 2009 4:10 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10793
Location: England
kc5tja wrote:
I maintain a 65816 emulator library, called "lib65816", for the Linux platform. ... However, I'd be happy to help anyone willing to write a simple console emulator using it.


I finally got around to having a look at lib65816, as found in your k2 emulator. I had some trouble getting it to work: the SDL_SetVideoMode call consistently fails on two ubuntu systems I have, but sprung into life on a third. So I did get to type .CREDITS into the Forth interpreter! Excellent!

For my purposes, I'd very much like to have a console version: ideally very much like lib6502's run6502 program, which allows interception of the ROM read and write routines to the console's stdin/stdout. (I'd also want to make the SDL gui optional, ideally optional at build time too.)

So, I'll see if I can get anywhere with that project, and may ask for help!

(For my purposes, the model B emulation is pertinent, because I'm working on a joint project to fit a 65816 into a model B. But the implementation is just 4 OS hooks and support for the banked memory hardware - it is a very minimal emulation.)

Cheers
Ed

Code:
lib6502 1.0 Copyright (c) 2005 Ian Piumarta
please send bug reports to: firstName (at) lastName (dot) com

usage: ./run6502 [option ...]
       ./run6502 [option ...] -B [image ...]
  -B                -- minimal Acorn 'BBC Model B' compatibility
  -d addr last      -- dump memory between addr and last
  -G addr           -- emulate getchar(3) at addr
  -h                -- help (print this message)
  -I addr           -- set IRQ vector
  -l addr file      -- load file at addr
  -M addr           -- emulate memory-mapped stdio at addr
  -N addr           -- set NMI vector
  -P addr           -- emulate putchar(3) at addr
  -R addr           -- set RST vector
  -s addr last file -- save memory from addr to last in file
  -v                -- print version number then exit
  -X addr           -- terminate emulation if PC reaches addr
  -x                -- exit wihout further ado
  image             -- '-l 8000 image' in available ROM slot

'last' can be an address (non-inclusive) or '+size' (in bytes)

[/code]


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Mar 01, 2009 4:20 pm 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
I'd be happy to help whereever I can. Please note that lib65816 assumes no specific I/O infrastructure; K2 is an emulator that uses lib65816, but the latter doesn't imply any specific ties to the Kestrel concept.


Top
 Profile  
Reply with quote  
PostPosted: Sat Mar 21, 2009 5:12 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10793
Location: England
I've got something now which acts as a minimal BBC model B emulator, and may be good enough for my immediate purposes:
Code:
$ ./minimal
Reading ROM.PRG
WARP FACTOR 5

BBC Computer 16K

BASIC

>PRINT PI
3.14159265


This is great for me: thanks for all the groundwork in the k2 emulator! (I've also borrowed from Ian Piumarta's run6502/lib6502 emulator of course, although you'll notice I haven't gone to the trouble of porting the nice command line interface.)

To trap the OS calls I made a couple of changes to lib65816 - there may well be better ways of doing this, but I'm no expert:
Code:
*** lib65816/cpu.h      2009-03-21 14:44:40.000000000 +0000
--- lib65816/cpu.h~     2009-02-28 10:37:34.000000000 +0000
***************
*** 127,133 ****
   */
 
  #define M_READ(a)       MEM_readMem(a, cpu_cycle_count)
- #define M_FETCH(a)      MEM_fetchMem(a, cpu_cycle_count)
  #define M_WRITE(a,v)    MEM_writeMem((a),(v), cpu_cycle_count)
 
 
--- 127,132 ----

Code:
*** src/dispatch.c      2009-03-21 14:43:13.000000000 +0000
--- src/dispatch.c~     2009-02-28 10:37:34.000000000 +0000
***************
*** 181,187 ****
      if (cpu_irq) goto irq;
  irq_return:
      if (cpu_wait) { cpu_cycle_count++; goto dispatch; }
!     opcode = M_FETCH(PC.A);  // will be M_READ except where we trap for emulation
      PC.W.PC++;
 
  #ifdef OLDCYCLES
--- 181,187 ----
      if (cpu_irq) goto irq;
  irq_return:
      if (cpu_wait) { cpu_cycle_count++; goto dispatch; }
!     opcode = M_READ(PC.A);
      PC.W.PC++;
 
  #ifdef OLDCYCLES


with a corresponding routine in the machine emulation (which you'll notice I've hard coded):
Code:
byte MEM_fetchMem(word32 address, word32 timestamp)
{
  if( address == 0x00FFEE || address == 0x00E0A4 ) { // oswrch and nvwrch
    return oswrch( address, timestamp );
  }
  if( address == 0x00FFF1 ) {
    return osword( address, timestamp );
  }
  if( address == 0x00FFF4 ) {
    return osbyte( address, timestamp );
  }

  return MEM_readMem( address, timestamp );
}


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Mar 21, 2009 5:29 pm 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
You've probably noticed in the K2 emulator that I use the WDM opcode to trap to the emulator for various things. That's the route I personally would have taken, but it obviously requires hot-patching the BBC ROM image at run-time.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Mar 21, 2009 5:52 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10793
Location: England
Ah - I didn't notice that, but thanks for the pointer! (I need a way to work with tracing)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Mar 28, 2009 8:36 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10793
Location: England
I've added a few more features from run6502 into my run65816.c - it now correctly reports 32k memory and allows loading of multiple mappable ROM images.

I had another thought about my MEM_FetchMem API change: would it be preferable to pass one or more flags to the MEM_ReadMem function, in effect the VP and VPA pin values, so that the MEM_ReadMem can emulate VP-detecting hardware, and also can trap OS calls by trapping selected instruction addresses?

Ed

Code:
$ ./run65816
usage: ./run65816 [option ...] -B [image ...]
  -B                -- (mandatory) minimal Acorn 'BBC Model B' compatibility
  -h                -- help (print this message)
  -l addr file      -- load file at addr
  image             -- '-l 8000 image' in available ROM slot

'last' can be an address (non-inclusive) or '+size' (in bytes)


Code:
$ ./run65816 -B -l c000 OS12.ROM BASIC2.ROM VIEW21.ROM
loading ROM file OS12.ROM
loading ROM file BASIC2.ROM
loading ROM file VIEW21.ROM
WARP FACTOR 5

BBC Computer 32K
         
BASIC

>*HELP

VIEW A2.1
  Stored
  Cmode

OS 1.20
>


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Mar 28, 2009 9:30 pm 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
It should be doable; I haven't done it because I don't need it personally. I can't imagine why it wouldn't be possible though.

I'm not sure the best way to implement it though. Understand that the core of lib65816 was taken from the abandonware "xgs" project. I didn't write the bulk of the code, and thus, really am not totally sure how it works inside.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Apr 03, 2009 2:29 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10793
Location: England
I've sent you a patch!

Cheers
Ed


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Apr 04, 2009 2:05 am 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
Just FYI -- I got the patch, but haven't applied it yet. I'm busy with my startup at the moment, but I will get to it as quickly as time permits.


Top
 Profile  
Reply with quote  
PostPosted: Sun Jan 20, 2013 12:08 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10793
Location: England
I've published my minimal run65816 wrapper to lib65816 - see viewtopic.php?p=23982#p23982

Cheers
Ed


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 14, 2023 8:27 am 
Offline

Joined: Wed Oct 31, 2018 6:45 am
Posts: 11
anyone tried to compile source for windows? got a lot of errors.


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 14, 2023 7:13 pm 
Offline

Joined: Tue Jul 05, 2005 7:08 pm
Posts: 990
Location: near Heidelberg, Germany
My xcbm console-based emulator has got some serious updates in the meantime...
https://github.com/fachat/xcbm

_________________
Author of the GeckOS multitasking operating system, the usb65 stack, designer of the Micro-PET and many more 6502 content: http://6502.org/users/andre/


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 14, 2023 8:44 pm 
Offline

Joined: Wed Jan 03, 2007 3:53 pm
Posts: 50
Location: Sunny So Cal
Excellent!

_________________
Machine room: http://www.floodgap.com/etc/machines.html


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 30 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: