My First C64/X16 Programs!

Chat about anything CX16 related that doesn't fit elsewhere
SlithyMatt
Posts: 913
Joined: Tue Apr 28, 2020 2:45 am

My First C64/X16 Programs!

Post by SlithyMatt »



1 hour ago, SerErris said:




Any idea how that works in X16?



The BASIC bank has a shadow Kernal jump table that points to a "bridge" that lets you do a JSRFAR to the Kernal bank and then return to the BASIC bank thanks to storing that bank index into a "magical" memory location ($0105 - a reminder to not touch any RAM between $0100 and $03FF!) that can be picked up after returning from the Kernal routine.

SerErris
Posts: 172
Joined: Sat Aug 08, 2020 9:18 am

My First C64/X16 Programs!

Post by SerErris »


Ah ... good to know and understand ... thanks for the explanation.

BruceMcF
Posts: 1336
Joined: Fri Jul 03, 2020 4:27 am

My First C64/X16 Programs!

Post by BruceMcF »



On 9/2/2020 at 1:03 AM, SerErris said:




So you would need to reduce the viewport massively. Full Screen DOOM or Wolfenstein is not realistic. (I know you did not mention Full Screen). 

 



Though AFAIU, full screen DOOM and full screen Wolfenstein are two distinct levels of difficulty, since Wolfenstein only requires vertical scaling. If you prescale Wolfenstein assets so that only (16*8)/8 scaling is required for intermediate scales between the pre-scaled levels, and work in low-res video mode, it seems like it could be done. 16x8/8 can be done as with intermediate step tables that fit into single 8K high RAM segments: eg, unsigned 8x4->12 fits into two 4K tables, one for the low byte and one for the high nybble of the result. Rather than shifting the "d4-d15" result, simply have a second 8x4->(12 lshift 4). So:

1] Bring in low 12 bit table High RAM segment

1] low byte of the 16, low nybble of the 8, store in the first two bytes of result, zero third

2] High byte of the 16, low nybble of the 8, add into the second and third bytes of result

3] Bring in high 12bit table High RAM segment

4] low byte of the 16, high nybble of the 8, add into the first two bytes of result, increment third byte on carry set

5] High byte of the 16, high nybble of the 8, add into the second and third bytes of result

6] RTS



And the division doesn't really need to be perfectly precise, so perhaps 4bitx(1/8bit)->4bit.12bit is enough precision ... that would involve two operaitons into result0 and two operations into result1, then shift the result0 down four bits before summing result1 in. ... And of course, that still leaves room for 4K of more tables.

So 16x8/8->16 in a total of 4 table set-ups and 16 LDA (TBLx),Y or ADC (TBLx),Y operations, one 24bit shift right by 4 bits and supporting glue.

You always use the same nybble twice not only because it is the same low or hygh nybble base of the resulting value, but also because the table reading heart is:

; Nybble in low bits of A, Table BANK in X, Y used, returns with previous BANK on top of stack.

SETTBL: LDY BANK : STX BANK : ORA #$A0 : STZ TBL0 : STA TBL0+1 : #ORA $B0 : STZ TBL1 : STA TBL1+1

L1: PLA : PLX : PHY : PHX : PHA : RTS

_____________________________

Note we don't have to mask the $A0+nybble page address for the $B0 table because $A0 is $10100000 and $B0 is %10110000 and we are looking for the pages corresponding to the same nybble in both cases.

geek504
Posts: 95
Joined: Wed Aug 26, 2020 4:52 pm

My First C64/X16 Programs!

Post by geek504 »



On 9/4/2020 at 1:12 AM, BruceMcF said:




Though AFAIU, full screen DOOM and full screen Wolfenstein are two distinct levels of difficulty, since Wolfenstein only requires vertical scaling.



That's some serious stuff there Bruce! Thanks for the food for thought! I'm starting to brush up on 3D fundamentals... rotating 3D cube without hidden line removal...

Wolf3D version 0.00001a LOL!

x16-cube.PNG.8e35872dd42196fef70e15a0354ba331.PNG

User avatar
desertfish
Posts: 1094
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

My First C64/X16 Programs!

Post by desertfish »


@geek504 cool I made that as well, am currently busy implementing the Elite game's ship models into it ?    How did you make your version of this? In basic or C or something else?

geek504
Posts: 95
Joined: Wed Aug 26, 2020 4:52 pm

My First C64/X16 Programs!

Post by geek504 »



23 minutes ago, desertfish said:




@geek504 cool I made that as well, am currently busy implementing the Elite game's ship models into it ?    How did you make your version of this? In basic or C or something else?



Proof-of-concept always in BASIC ? then slowly adding trig tables, SYS calls to assembly code, maybe a C version, then finally full assembly!

Might as well ask now since I am trying to eliminate FLICKER: Is it possible to have two GRAPHICS pages (mode $80) and flip between them? (aka page-flipping). If not, is there any other graphics mode that does?

User avatar
desertfish
Posts: 1094
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

My First C64/X16 Programs!

Post by desertfish »


Good stuff, @geek504  .  I don't have an answer to your question and am struggling with a similar idea myself as you can read on the description of my own demo program https://www.commanderx16.com/forum/index.php?/files/file/71-3d-wire-frame-spinning-cube/    I was wondering if there is a way to wait for Vertical Blank.   (won't help much to reduce flicker still I am afraid because I don't think the program will be fast enough to redraw everything within one frame, but hey)

Elektron72
Posts: 137
Joined: Tue Jun 30, 2020 3:47 pm

My First C64/X16 Programs!

Post by Elektron72 »


There is a vector located at $0314 that points to the interrupt routine (which is by default called at vertical blank every frame). Changing this vector to point to your own code will allow you to write a routine that runs at vertical blank. To make sure the original interrupt routine still runs, save the original value of the vector, and jump there at the end of your routine.

User avatar
desertfish
Posts: 1094
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

My First C64/X16 Programs!

Post by desertfish »


Hm, interesting, didn't realize that the IRQ vector  might be the same as on the C64.   Thanks.

geek504
Posts: 95
Joined: Wed Aug 26, 2020 4:52 pm

My First C64/X16 Programs!

Post by geek504 »


We might still have a chance on the X16!





... well, more than a chance... look at this!

http://feed4gamers.com/game-news/144911/wolfenstein-3d-for-commodore-64-version-11.htm

Post Reply