Jump to content
IGNORED

Channel F / F8 programming questions


Recommended Posts

Hey, I'm new here, hope starting a new thread for this is OK. I'm working on a little Channel F project and I have a couple of questions so far, will probably have more over the next days/weeks as I encounter them...

 

First off: Is there really no way to OR two registers? There's XS and NS for XOR and AND respectively, but no OR (AS can be used to OR one high and one low nibble though). I guess I can do OM which does an OR of A and the value at DC0, but in order to be able to use that for a non-hardcoded value I need to use Schach RAM to put the byte I need to OR with A? That sounds so extremely convoluted I almost can't believe it! But I can work with it, of course, unless there's another way.

 

Second: I have about 300 lines of code so far but I haven't dared draw anything to the screen yet, hehe. Just so I understand this correctly, you draw per-pixel by saying what color the pixel should be. You set it to either red, blue, green or transparent. The background color is defined by the palette columns; if it's black, all colors except transparent are displayed as white instead. Does that sum it up?

 

Thanks!

Link to comment
https://forums.atariage.com/topic/298572-channel-f-f8-programming-questions/
Share on other sites

I have no idea about F8 programming specifically but in digital logic, you can do OR with an AND gate and some inverters, so I guess it would also work with programming.

 

So, you invert both registers (XOR each with FF), then AND them together, then XOR the result with FF and you have done an OR. If I am remembering right.

 

 

Welcome to Channel F programming! We need more people, because right now, basically it's just me and e5frog.

EDIT: You might want to check out the channel F thread over in the Classic Gaming subforums. It's cool.

Hi tobiasvl, welcome to the Fairchild Channel F love!

 

If you can get anything working with it, then please tell me how you did it, because I'm still trying to work it out! :P

 

I understand the playfields, I've managed to get buttons to actually do stuff, but other than that I'm still pretty stuck.

Hehe, well, right now I'm doing something with little artistic merit in itself, but maybe some practical value.. We'll see!

 

The F8 architecture seems nice enough, although having to wrap my head around ISAR is the biggest hurdle so far. The RAM/register dichotomy is really nice actually, being able to easily increment and decrement a "register pointer", but the missing "OR with register" instruction means it's harder than it ought to be to map a number to the corresponding register, which was the use-case I had when I asked originally. Based on the XOR/AND/XOR idea from batari I made this ugly macro:

	MAC OS
	; adds missing instruction: OS r
	; modifies r0
	com
	lr 0, a
	lr a, {1}
	com
	ns 0
	com
	ENDM

Thanks for the link to the other thread, it seems a bit more hardware/collector focused and that's not really my jam, but cool to see so many people interested in the system!

 

One other question: What's the best emulator choice nowadays, and especially on Linux? I see VESWiki uses MESS for Windows, but that's since been swallowed up by MAME, hasn't it? I fired up MAME and didn't understand anything of how it worked, so I'm using the development package from VESWiki right now with MESS from 2004 on my Windows partition.

Edited by tobiasvl
better macro

Trucking along here... How do local timer interrupts work exactly? I've read the F8 Guide to Programming, and the clock example in 8.3.3 is clear enough, but I don't understand how to tell the CPU where the interrupt routine is located. The example orgs the interrupt routine to $0200, but it doesn't seem to tell the CPU that it's there. Section 8.2.7 talks about an "interrupt address register" which holds the address for that example, but as far as I understand that's only the case when the interrupt is triggered by an external device, not when it's local... Well, I'm not sure I understand it at all.

 

Are there any timer examples in any of the disassembled Channel F ROMs?

I might just be talking to myself here, but two more things have been a pain in the butt:

  • Shift instructions don't affect the carry flag, and consequently there's no "shift with carry" instructions either. Not a big deal, easy to circumvent. A bit annoying though.
  • The ADC instruction treats A as a signed two's complement number??? Okay, they really didn't want to have a "subtract from DC" instruction, fair enough, but this is extremely annoying when I want to add $80 or more to the DC. Are there any clever F8 idioms here that people use? This one really had me stumped for a while, would probably be nice if http://channelf.se/veswiki/index.php?title=Opcode mentioned that fact. This is what I ended up doing in my usecase:
; A holds an offset in a buffer: The 5 upper bits are the Y coordinate and the 3 lower bits are the X coordinate
	dci $2f00			; location of buffer
	bp .adcHack			; if the number to add to $28f0 is less than $80, we just add it
	ni %01111111			; if not, we clear the "sign" bit
	dci $2f80			; and address the middle of the buffer instead
.adcHack:
	adc				; add unsigned A

This is going to be some real spaghetti code, I might hire @e5frog to do an optimization pass after I'm done ?

Edited by tobiasvl

Personally, I learn more from anyone sharing any code when it comes to Assembly because I really don't have much clue :P I've probably learnt more from what you've posted than I can offer myself in response.

 

I did ask e5frog if he could open up the wiki so those of us learning can help contribute to it, dunno if he has made it available for others to register yet though.

Assembly isn't that hard, you just need to consider how the memory is laid out and how it can flow between registers. Which is clearly easier said than done. In the example above, since I realized after posting my last reply that the address is fixed and the buffer is just from $2F00 to $2FFF, so I can simply do this instead:

	lr ql, a
	li $2F
	lr qu, a
	lr dc, q

I do add a byte to an arbitrary address somewhere else, though, so I'll still have to use something like what I wrote above there, luckily!

 

Anyway. Sometimes I think assembly is easier than high-level programming. It's like building with legos. It's hard to quickly understand what a piece of assembly code does afterwards though, so I try to comment it fairly heavily while I write it. I'll share the code later when I've weeded out all this embarrassing stuff, in case it's useful.

Edited by tobiasvl

Nice to see a fellow Northman here, programming for the F8.
Seems you have experience of other types of assembly language and now you're frustrated you can't do the same with this one. ;-)

"Luckily" I have done most of my assembly programming for the F8 and some for the Commodore 64 and VIC-20 (apart from 6809 and 68000 in college and a little bit of PIC) - so I don't know any better.

 

Regarding timer interrupts, I believe an interrupt only stores PC0 in PC1 and also destroys the accumulator value which may make things difficult.

I need to read up on that... as I haven't tried it and I'm not sure MESS/MAME has support for it, but it's not impossible, I know Sean Riddle was involved correcting a few details. 

3850 has an INT REQ pin that's only connected to the cartridge port so an external device should be able to to cause an interrupt. The SABA #20 has it hooked up, so it's possible it's used, it should in that case use IN/INS/OUT/OUTS commands to handle the interrupt. But I can't find anything in the raw disassembly, just ports 0, 1, 4 and 5 as usual, no op-code "BC" as it should be. 
http://channelf.se/veswiki/index.php?title=Disassembly:SABA_Videoplay_20

 

The internal I/O-ports $0C-$0F handles interrupt and timer on the 3853. 

To set interrupt address $FF00: 

LI   $FF

OUT  $C

INC

OUT  $D

http://channelf.se/files/channelf/f3852_53.pdf


 

When adding or subtracting to the data counter using the Q-registers (or H-register) are quite handy, there's also the possibility to use a loop and add (or subtract, 2-complemented data) increments

 

Graphics need the color and two coordinates set on the ports before you execute the command to write them, real machines need a delay before next pixel can be sent. It's pretty clear in the VESwiki. You don't have to send all data every time unless it changes, if you draw a green object you can set the color once and the mangle in the coordinates and "make it so" command for all your dots. 

 

 

Regarding MESS, you can download older versions that doesn't use the horrible MAME graphic interface that totally destroyed the joy of MESS. 

I believe I use MESS 0.133b the most, it doesn't have the MAME-type menus at all. I should perhaps update the development package. Nothing wrong with using a couple of year old emulator for a 43 year old machine.   ;-)

I use v0.187 when recording video, not that it happens that often. 

 

 

  • Thanks 1
  • 6 months later...

Hey! Hope it's OK to bump this, there's a limit to how many niche Channel F programming threads I'm comfortable with creating here.

 

My project hit a little snag with the timer interrupt stuff, and then the lockdown happened and I was stuck at home with two kids for several weeks, etc etc. Picking up the F8 again now though.

 

But I realized I never thanked @e5frog for his great reply – sorry. It was indispensable. Still didn't get the timer to work like I want it to, but that's on me and not you. MESS is great. You're quite right, I have experience with other assembly languages/architectures. I do have experience with several of them, though (M6800/6502, 8080/8085, Z80/Game Boy, probably more) and I still think F8 is the strangest. But that's part of the appeal!

 

When reading up on the F8 I realized there's no traditional (reverse) opcode table on it anywhere, at least that I've found. So I've started making one. It's not done yet, but here's what I have so far: https://tobiasvl.github.io/opcode-tables/f8/classic – any thoughts would be welcome. It's interesting to see how the decoding is laid out (there's also an octal view, selectable up top, since the matrix on the F8 is mostly octal). I plan to add some more clarifying information below the table (especially when it comes to registers and ISAR), perhaps some more tooltip texts to explain operands.

 

A couple of questions I just had, but which I guess I can find the answer to myself:

  • Do the three illegal opcodes $2E, $2D and $2F have any effect?
  • Is 15 a valid scratchpad register operand? The F8 programming manual just says that 0 through 11, and 12/S, 13/I and 14/D are allowed. So I guess not, but there's nothing about that in the table on the VESwiki. So are $4F and $5F illegal opcodes? Of course if they're legal they would be equivalent to $03 and $07, but what about $3F, $CF, $DF, $EF and $FF which all would do different things to register 15? I can probably test this myself in MESS.
Edited by tobiasvl

Not sure MESS handles the timer interrupts, I have thought about testing it out myself when timing stuff (seconds counter or whatever). 

You'd have to use DI/EI so it doesn't mess up the code. Do you know if the interrupt flag will be held until there's a EI, if it's disabled when the interrupt happens?

If you get any results, please share. 


Nice table, it wasn't readable on my phone but it looks nice on the computer screen.

 

I wondered about that as well the other day when checking the table after finding an error. Not sure MESS is the best place to try it, if they have used the same information. It should be possible to check it in the MESS/MAME code (somewhere). 

 

According to Lowell Turner those $xF result in NOP:

http://www.nyx.net/~lturner/public_html/F8_ins.html

 

EDIT: 

Registers 12, 13, 14 and 15 are the K and Q 16-bit registers so perhaps it would be odd to be able to call r15 directly like that. 

 

 

 

Edited by e5frog

Ah, thank you! I'm guessing Turner is correct, it fits with what the F8 Programming Guide says. Yes, it'd be strange if you could LD r15 like that, but there's no AS QL, for example, so it'd be nice to have those logical instructions work for r15. It seems they don't though. I can double check with MESS/MAME.

 

I'll look at making the table readable on a phone (probably with scrolling, as it can't possibly fit horizontally). Thanks for pointing it out. I'll also replace the r15 opcodes with NOPs. (Perhaps the same should be done on the wiki.)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...