vic20-emu (another emulator)
Moderator: Moderators
vic20-emu (another emulator)
I'm having fun writing another VIC-20 emulator
It's not totally new, I've taken the code from Andre Weissflog's Tiny 8 bit emulators and recompiled / adapted for the web browser.
Andre Weissflog's source code is special because he emulates every chip separately at the pin level, and then he connects them together as in the real hardware. It's a very interesting approach that lets you get a better understanding on how small details work in a 8 bit machine.
It's all written in C and every "chip" resides in a single .h file that you can #include. Emulation is not perfect, some games don't work, but since the project is open source you can fix bugs and submit improvements.
I compile C to WebAssembly, which is a new web technology that lets you run compiled code at almost native speed (it's a sort of stack-based virtual machine). The I use Javascript to host the webassembly code and interact with the user.
You can run the vic20-emu here.
The purpose of this emulator is to have something that I can easily hack and script.
It's not totally new, I've taken the code from Andre Weissflog's Tiny 8 bit emulators and recompiled / adapted for the web browser.
Andre Weissflog's source code is special because he emulates every chip separately at the pin level, and then he connects them together as in the real hardware. It's a very interesting approach that lets you get a better understanding on how small details work in a 8 bit machine.
It's all written in C and every "chip" resides in a single .h file that you can #include. Emulation is not perfect, some games don't work, but since the project is open source you can fix bugs and submit improvements.
I compile C to WebAssembly, which is a new web technology that lets you run compiled code at almost native speed (it's a sort of stack-based virtual machine). The I use Javascript to host the webassembly code and interact with the user.
You can run the vic20-emu here.
The purpose of this emulator is to have something that I can easily hack and script.
- chysn
- Vic 20 Scientist
- Posts: 1205
- Joined: Tue Oct 22, 2019 12:36 pm
- Website: http://www.beigemaze.com
- Location: Michigan, USA
- Occupation: Software Dev Manager
Re: vic20-emu (another emulator)
My first question is, how do you load a file into it?
VIC-20 Projects: wAx Assembler, TRBo: Turtle RescueBot, Helix Colony, Sub Med, Trolley Problem, Dungeon of Dance, ZEPTOPOLIS, MIDI KERNAL, The Archivist, Ed for Prophet-5
WIP: MIDIcast BASIC extension
he/him/his
WIP: MIDIcast BASIC extension
he/him/his
Re: vic20-emu (another emulator)
using today's version: drag & drop a ".prg" file on the screen and then RUN.
You can also open the Javascript console (key F12) and issue the following commands:
- `load("file.prg" [,start])` loads a file at the specified address
- `save("file.prg" [,start, end])` saves a file
- `download("file.prg")` gets the file as a browser download
- `remove("file.prg")` remove file from browser's cache
- `dir()` lists files on browser's cache
- `vic20.config(n)` configures memory (n from 0 to 5)
- `vic20.reset()` resets the VIC20 (also via CTRL+ALT+BREAK keys)
- `vic20.peek(address)`
- `vic20.poke(address, data)`
Re: vic20-emu (another emulator)
you can also emulate a joystick with cursor keys + space, toggling via "SCROLL LOCK" key
- chysn
- Vic 20 Scientist
- Posts: 1205
- Joined: Tue Oct 22, 2019 12:36 pm
- Website: http://www.beigemaze.com
- Location: Michigan, USA
- Occupation: Software Dev Manager
Re: vic20-emu (another emulator)
Cool, I'll play around with it!
How about enabling expansion options? If there's documentation somewhere, I'll shut up with all the questions
Is that what config() does?
How about enabling expansion options? If there's documentation somewhere, I'll shut up with all the questions
Is that what config() does?
VIC-20 Projects: wAx Assembler, TRBo: Turtle RescueBot, Helix Colony, Sub Med, Trolley Problem, Dungeon of Dance, ZEPTOPOLIS, MIDI KERNAL, The Archivist, Ed for Prophet-5
WIP: MIDIcast BASIC extension
he/him/his
WIP: MIDIcast BASIC extension
he/him/his
- chysn
- Vic 20 Scientist
- Posts: 1205
- Joined: Tue Oct 22, 2019 12:36 pm
- Website: http://www.beigemaze.com
- Location: Michigan, USA
- Occupation: Software Dev Manager
Re: vic20-emu (another emulator)
I don't have a Scroll Lock key, so I might not be able to do any joystick things.
I frequently encounter stability issues. For example, I was typing in a program and the system sort of locked up. The cursor is still blinking, but it's unresponsive. Earlier, the editor sort of freaked out and typed %"%"%" over and over again and then wouldn't respond. When this happens, vic20.reset() resets the emulator, but does not correct the responsiveness issue.
I noticed that SHFLAG ($28d) does not register Shift. For example, try
Code: Select all
10 PRINT PEEK(653):GOTO 10
I'm sure you're in the early stages of this, and it shows promise.
If there's any way to dump state in the JS console for your review, I'd be happy to send it to you.
VIC-20 Projects: wAx Assembler, TRBo: Turtle RescueBot, Helix Colony, Sub Med, Trolley Problem, Dungeon of Dance, ZEPTOPOLIS, MIDI KERNAL, The Archivist, Ed for Prophet-5
WIP: MIDIcast BASIC extension
he/him/his
WIP: MIDIcast BASIC extension
he/him/his
Re: vic20-emu (another emulator)
as for the SCROLL LOCK key, I will ad another shortcut. By the way what keyboard do you have?
I'm aware of the problems you described, they are not related to the emulator itself, but to the keyboard emulation. Currently there is a "logical" keyboard, meaning that ASCII symbols are translated into VIC 20 hardware keys. This has the advantage of working with any keyboard layout (english, italian etc), e.g. what you type is what you see, but SHIFT has to be handled separately and causes glitches when a shifted symbols produce a non-shifted vic 20 key.
The alternative I'm considering is to emulate an "hardware" keyboard: most symbols won't match but they will appear in the same keyboard row and column of the original vic20.
Yes, "vic20.config(n)" is what lets you change the memory configuration. I've to check because it seems to me that the 3K expansion config is missing.
P.S. I've drastically improved the audio emulation, now it can run Berzerk MMX+
I'm aware of the problems you described, they are not related to the emulator itself, but to the keyboard emulation. Currently there is a "logical" keyboard, meaning that ASCII symbols are translated into VIC 20 hardware keys. This has the advantage of working with any keyboard layout (english, italian etc), e.g. what you type is what you see, but SHIFT has to be handled separately and causes glitches when a shifted symbols produce a non-shifted vic 20 key.
The alternative I'm considering is to emulate an "hardware" keyboard: most symbols won't match but they will appear in the same keyboard row and column of the original vic20.
Yes, "vic20.config(n)" is what lets you change the memory configuration. I've to check because it seems to me that the 3K expansion config is missing.
P.S. I've drastically improved the audio emulation, now it can run Berzerk MMX+
Re: vic20-emu (another emulator)
for the joystick you can use the Javascript command:
vic20.emu_joy(true);
vic20.emu_joy(true);
- chysn
- Vic 20 Scientist
- Posts: 1205
- Joined: Tue Oct 22, 2019 12:36 pm
- Website: http://www.beigemaze.com
- Location: Michigan, USA
- Occupation: Software Dev Manager
Re: vic20-emu (another emulator)
Neat! I have a MacBook Pro keyboard.
VIC-20 Projects: wAx Assembler, TRBo: Turtle RescueBot, Helix Colony, Sub Med, Trolley Problem, Dungeon of Dance, ZEPTOPOLIS, MIDI KERNAL, The Archivist, Ed for Prophet-5
WIP: MIDIcast BASIC extension
he/him/his
WIP: MIDIcast BASIC extension
he/him/his
Re: vic20-emu (another emulator)
Nice. But who need another soft emulator when the answer is FPGA? Why not complete the vicy cores?
Valid rule today as earlier: 1 Byte = 8 Bits
-._/classes instead of masses\_.-
-._/classes instead of masses\_.-
- chysn
- Vic 20 Scientist
- Posts: 1205
- Joined: Tue Oct 22, 2019 12:36 pm
- Website: http://www.beigemaze.com
- Location: Michigan, USA
- Occupation: Software Dev Manager
Re: vic20-emu (another emulator)
You're talking about this as if nippur72 would have otherwise been able to spend his or her time furthering the FPGA cause had it not been for this pesky emulator project getting in the way. That's not necessarily the case.
The way I see it, there's lots of value to continued emulator development, as long they bring something new to the game. For example, this project has the advantage of being platform-agnostic. Also, I can run multiple emulations at a time, which I cannot do with VICE for macOS. I cannot drag .prg files onto VICE, only .d64 files, which isn't hard but does add some friction to the process. So there are already some advantages to this.
Currently, it's pretty severely crippled. I don't think I've gone more than five minutes of use without the emulator giving up on accepting keyboard input. But that's why we have people try things.
VIC-20 Projects: wAx Assembler, TRBo: Turtle RescueBot, Helix Colony, Sub Med, Trolley Problem, Dungeon of Dance, ZEPTOPOLIS, MIDI KERNAL, The Archivist, Ed for Prophet-5
WIP: MIDIcast BASIC extension
he/him/his
WIP: MIDIcast BASIC extension
he/him/his
Re: vic20-emu (another emulator)
that should work just fine in a recent VICEI cannot drag .prg files onto VICE, only .d64 files
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
- chysn
- Vic 20 Scientist
- Posts: 1205
- Joined: Tue Oct 22, 2019 12:36 pm
- Website: http://www.beigemaze.com
- Location: Michigan, USA
- Occupation: Software Dev Manager
Re: vic20-emu (another emulator)
Oh, sweet, I'll update and give it a shot!
Update: Well, it sort of works. Dragging a .prg into VICE loads the dragged program; but it resets the emulator and removes previously-dragged .prg files from memory.
Last edited by chysn on Sun Jul 19, 2020 2:47 pm, edited 2 times in total.
VIC-20 Projects: wAx Assembler, TRBo: Turtle RescueBot, Helix Colony, Sub Med, Trolley Problem, Dungeon of Dance, ZEPTOPOLIS, MIDI KERNAL, The Archivist, Ed for Prophet-5
WIP: MIDIcast BASIC extension
he/him/his
WIP: MIDIcast BASIC extension
he/him/his
-
- Vic 20 Devotee
- Posts: 231
- Joined: Tue Sep 04, 2018 2:40 am
- Website: http://davbucci.chez-alice.fr
- Location: Grenoble - France
Re: vic20-emu (another emulator)
That's a cool emulator. I tried it with a small game I wrote, Alien Invasion:
http://sleepingelephant.com/ipw-web/bul ... 9&p=102004
It works quite well, but the bottom part of the screen is partially cut. This is probably due to the particular screen layout I used, but people that played to the game never reported that the spaceship was off-screen on real hardware (both PAL and NTSC), at least with reasonably good TV's.
EDIT: on the other hand, Cavern Explorer does not seems to work properly
http://sleepingelephant.com/ipw-web/bul ... 2&p=102571
http://sleepingelephant.com/ipw-web/bul ... 9&p=102004
It works quite well, but the bottom part of the screen is partially cut. This is probably due to the particular screen layout I used, but people that played to the game never reported that the spaceship was off-screen on real hardware (both PAL and NTSC), at least with reasonably good TV's.
EDIT: on the other hand, Cavern Explorer does not seems to work properly
http://sleepingelephant.com/ipw-web/bul ... 2&p=102571
- Mike
- Herr VC
- Posts: 4890
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Re: vic20-emu (another emulator)
chysn wrote:I cannot drag .prg files onto VICE, only .d64 files
groepaz wrote:that should work just fine in a recent VICE
More details to be found here: How to start .prg files in VICE.chysn wrote:Oh, sweet, I'll update and give it a shot!
Update: Well, it sort of works. Dragging a .prg into VICE loads the dragged program; but it resets the emulator and removes previously-dragged .prg files from memory.