Hi,
The 2 parts of the subject are not related but I wanted to kill 2 birds with one stone
* Is there any expansion card, or cartridges that use for any purpose the address space $9130-93FF ?. I know that in the
doc its says 'future expansion' but is there " anyone " using it ?
* Is there many games or apps that use the illegal opcodes of the 6502? Any list or numbers? I ask this to see if I can
get mostly 100% compatibility by using the W65C02.
thanks,
M
I/O0 and illegal opcodes
Moderator: Moderators
- Mike
- Herr VC
- Posts: 4941
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Re: I/O0 and illegal opcodes
(Note that address range is actually referred to as part of I/O0 as evident from the schematics, not I/O1 as you originally wrote in the topic title. I changed the topic title to follow suit.)mythic66 wrote:[Are] there any expansion [...] cartridges that use for any purpose the address space $9130-$93FF? I know that in the doc it says 'future expansion' but is there "anyone" using it?
There is no select signal for the I/O0 address range that appears at the cartridge expansion port. Following that, there does not exist any cartridge that would use the addresses $9130..$93FF, neither would one be able to build one. Any expansion that makes use of this address range would need to be realized on the VIC-20 mainboard itself. That has actually been done indeed. More info here.
BASIC and KERNAL in the VIC-20 only use the documented opcodes, but there does exist software that uses the so-called "illegal opcodes". If you install a W65C02 into your VIC-20, you will have to live with less than 100% compatibility in that regard.[Are] there many games or apps that use the illegal opcodes of the 6502? Any list or numbers? I ask this to see if I can get mostly 100% compatibility by using the W65C02.
...
Yet both parts of the subject would have deserved an own topic, if only to prevent confusion in any follow-up discussion.The 2 parts of the subject are not related but I wanted to kill 2 birds with one stone
Re: I/O0 and illegal opcodes
To add to this: not seldom in old games there are undocumented opcodes executed not because the coder used them intentionally, but because they are a result of accidental memory corruption during development. (This is also true for use of uninitialized RAM, which happens surprisingly often in VIC20 games)but there does exist software that uses the so-called "illegal opcodes".
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
Re: I/O0 and illegal opcodes
I'd say if the illegal opcodes are used unintentionally and serve no true purpose (i.e. making code faster or more compact) they warrant a crack/hack to improve them. Otherwise I only know of VIC Doom that uses illegals, and Kweepa already regrets this since the effect seems minor.
One of my graphic-modes uses the illegal opcode SAX as this is the only way to show the graphics without changing the volume register as well.
Also I know the C64-fastloader Spindle uses illegals to do GCR-decoding on the fly which was deemed impossible before.
So, 99.9% of software will work, but there will always be some cool edge cases that require illegal opcodes. Supporting a W65C02 is fine, but if you can also support using the original 6502.
One of my graphic-modes uses the illegal opcode SAX as this is the only way to show the graphics without changing the volume register as well.
Also I know the C64-fastloader Spindle uses illegals to do GCR-decoding on the fly which was deemed impossible before.
So, 99.9% of software will work, but there will always be some cool edge cases that require illegal opcodes. Supporting a W65C02 is fine, but if you can also support using the original 6502.
- chysn
- Vic 20 Scientist
- Posts: 1204
- Joined: Tue Oct 22, 2019 12:36 pm
- Website: http://www.beigemaze.com
- Location: Michigan, USA
- Occupation: Software Dev Manager
Re: I/O0 and illegal opcodes
I often use the multi-byte illegal NOPs, TOP ($3c, a.k.a. SKW) and DOP ($34, a.k.a. SKB) as selectors, because they're terribly useful:
I'm not hesitant to use these because on 65C02 they correspond to BIT abs,X and BIT zp,X, respectively, so they should maintain the same functionality (as long as I don't rely on the flags that BIT sets). For the most part, I don't see the illegal instructions as making a lot of sense, conceptually, so my use isn't going to go beyond the fancy NOPs.
Code: Select all
Load: jsr SETNAM, etc.
jsr LOAD
bcc ok
jmp LoadErr
ok: rts
LoadErr: lda #LOAD_ERR
.byte $3c ; Skip next two bytes
MemErr: lda #OUT_OF_MEM_ERR
.byte $3c ; Skip next two bytes
RangeErr: lda #OUT_OF_RANGE_ERR
jsr DisplayError
jmp WarmStart
Last edited by chysn on Wed Sep 13, 2023 12:50 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
Re: I/O0 and illegal opcodes
All the modern loaders doAlso I know the C64-fastloader Spindle uses illegals to do GCR-decoding on the fly which was deemed impossible before.
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
Re: I/O0 and illegal opcodes
It's a very common pattern, but, out of curiosity, why not just use the BIT opcodes ($24 and $2C)? The Vic-20 KERNAL (and many other 6502 programs) do this.
The only reason I can imagine is to preserve the status register, but then this:
will be explicitly the wrong behaviorchysn wrote: I'm not hesitant to use these because on 65C02 they correspond to BIT abs,X and BIT zp,X, respectively
I have nothing against illegals myself. It's an extreme optimization in most cases, but there are applications for that.
Seems like they're very popular on the Atari-2600, which often demands an extra cycle here and there.
- chysn
- Vic 20 Scientist
- Posts: 1204
- Joined: Tue Oct 22, 2019 12:36 pm
- Website: http://www.beigemaze.com
- Location: Michigan, USA
- Occupation: Software Dev Manager
Re: I/O0 and illegal opcodes
That's a fair question, and I've thought about it a lot in the course of my assembler design. I think that code is about communication with people as well as machines, so it's totally with that aesthetic in mind. Meaning is better conveyed by this:
or this:
than this:
Since there's pretty much no downside to using those ?OP/SK? "instructions" instead of BIT, I adopt the practice for my own sense of harmony.
Re: I/O0 and illegal opcodes
Huh, never thought of it in terms of disassembly ergonomics. Neat!chysn wrote: That's a fair question, and I've thought about it a lot in the course of my assembler design. I think that code is about communication with people as well as machines, so it's totally with that aesthetic in mind. Meaning is better conveyed by this:
- JonBrawn
- Vic 20 Devotee
- Posts: 275
- Joined: Sat Sep 11, 2021 10:47 pm
- Website: http://youtube.com/@vicenary
- Location: Austin TX USA
- Occupation: CPU design engineer
Re: I/O0 and illegal opcodes
Victor, my FPGA replacement for the 6560/1, uses many of the addresses in that range (the ones that do not collide with the regular VIC chip or the two VIAs). They are used for re-flashing the firmware and programming the user-definable colour palette. Having said which, Victor will only accept accesses to those locations after the magic unlock values have been written to the read-only VIC registers.
Note that this address range is a veritable minefield - the VIC and the two VIAs do not do complete address decoding, so multiple copies of their registers appear in that space, sometimes two or three of the devices being addressed at the same time, leading to possible bus contentions.
Working on FPGA replacement for 6560/6561
https://youtube.com/@vicenary
https://youtube.com/@vicenary