Jump to content
tobiasvl

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!

Share this post


Link to post
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.

 

 

Share this post


Link to post
Share on other sites

Oh, yeah! You're right, I vaguely remember this from college myself. NAND is functionally complete on its own. Thanks, I should've thought of that trick!

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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...