English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 03 October 2008, 15:09   #1
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
6502 Asm

Totally the wrong forum really for a place where we should be talking about Amiga related coding but does anyone on here do any 6502 asm on C64? I've been trying to learn some over the last couple of days.

I've only done one routine so far - I knocked together a very quick and dirty scroll text routine which works (just about...) but the text scrolls too fast and I wanted to know if anyone knew of an elegant way to slow it down so it's readable...?

If I really shouldn't be posting about non-Amiga related coding stuff here then I'll apologise in advance to the moderators now and wait for the post to be deleted!
pmc is offline  
Old 03 October 2008, 15:37   #2
IFW
Moderator
 
IFW's Avatar
 
Join Date: Jan 2003
Location: ...
Age: 52
Posts: 1,838
Generally speaking - regardless of platform - you need to synchronize your screen update with the screen refresh and match a muliple of the screen refresh rate.
The normal way of achieving this is using the vertical blanking interrupts to control screen updates, switching screens etc and you may use the raster line position as well.
IFW is offline  
Old 03 October 2008, 15:44   #3
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
Thanks IFW.

I set up an interrupt that gets triggered at raster position $00 and calls the code that writes the next character to the screen, x-scrolls the characters left (using lower 3 bits of $d016) and then copies all character codes from their current location to the one next left each time $d016 x-scroll reaches zero.

The scrolling seems to be fairly smooth doing it like this it's just that it zips past too fast - is there something neater I can do than just waiting say for every second or third time raster position zero gets reached?
pmc is offline  
Old 03 October 2008, 15:45   #4
Jherek Carnelia
Dazed and Confused
 
Jherek Carnelia's Avatar
 
Join Date: Dec 2001
Location: portsmouth/uk
Posts: 242
Here is some C64 assembly and programming stuff. Maybe it's useful.

Last edited by Jherek Carnelia; 09 April 2011 at 22:22.
Jherek Carnelia is offline  
Old 03 October 2008, 20:00   #5
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
Thanks Jherek, that's useful general information.

I tried the method I mentioned in my previous post by changing the routine so that it now waits for the raster beam to reach position zero five times before doing any scrolling. That slows the scroller down enough so it's readable but it's still a bit jerky.

Never mind... I'll keep trying to get it nice and shmoove.
pmc is offline  
Old 03 October 2008, 20:16   #6
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
Try syncing on another line than 0. I can't recall the hardware details but I think that unless you write the MSB of the raster position in $D011 the VIC will trigger the interrupt every time the lower 8 bits match, and they will match line 0 twice per frame.

It could also be that you have some logical error in your code. Here's a very simplified example to compare with:

Code:
	ldy #0
	ldx #8

main:	lda #$80
	cmp $d012
	bne *-3
	lda #$81
	cmp $d012
	bne *-3

	dex
	bpl done

	ldx #0

move:	lda $0401, x
	sta $0400, x
	inx
	cpx #39
	bne move

	lda scrolltext, y
	sta $0427
	iny
	ldx #7

done:	stx $d016
	jmp main

Last edited by Leffmann; 03 October 2008 at 20:42.
Leffmann is offline  
Old 05 October 2008, 13:46   #7
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
Thanks for that Leffman.

I slept on it and then looked at my code again and found a problem with the loop logic that I've now fixed and things are looking a lot better with the scroller now.
pmc is offline  
Old 14 October 2008, 23:36   #8
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
The C64 actually uses a 6510 CPU!
Photon is offline  
Old 15 October 2008, 00:39   #9
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
And the 1541 which you can also program uses a 6502 so all is fine again. lda/sta is all you need anyway =)
StingRay is offline  
Old 15 October 2008, 20:46   #10
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
DualCore power! "Woohoo!" (c) Homer
Photon is offline  
Old 16 October 2008, 15:05   #11
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
@ Photon - you're absolutely right but you're also pedantic too! I stand corrected.

@ StingRay - you always make everything to do with asm sound so easy - if only I found it all that simple - I'd have more hair for a start...

@ Leffman - I was reading some info on the VIC-II.

This document states that for timing of a raster line: "Raster line 0 is an exception: In this line, IRQ and incrementing of RASTER are performed one cycle later than in the other lines."

Looks like you were right about raster line 0 being a special case.
pmc is offline  
Old 17 October 2008, 22:20   #12
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
PMC

I didn't know that actually. I was talking about a different situation, but that's good to know.

Anything cool to show yet? If you're looking for help with C64 programming then you will find the true experts in #C-64 on the ircnet network.
Leffmann is offline  
Old 18 October 2008, 12:56   #13
musashi5150
move.w #$4489,$dff07e
 
musashi5150's Avatar
 
Join Date: Sep 2005
Location: Norfolk, UK
Age: 42
Posts: 2,351
Is there no end to your talents pmc? As if Amiga wasn't enough for you you've now become a hardware basher on the 64 as well. Good work
musashi5150 is offline  
Old 18 October 2008, 18:00   #14
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
Leffman - errr, no nothing very cool to show you yet I'm afraid - unless you would count a rather lame built in character set scroller text as cool...

At the moment I'm just playing really and trying to learn about the hardware. I've read some stuff on codebase64.org and floated around as a guest on CSDb a bit. Those guys on there seem to be the cream of the C64 scene though. The stuff they put out is way, way ahead of anything I think I could ever do but it's fun to try new things anyway.

Ideally for me the next stop will be to try to understand all the VIC timing stuff and make a stable raster routine and take it from there. Maybe then I could do some raster splits or open the sideborders, that'd be cool.

@ musashi5150 - one tries, one tries but as you well know, when it comes to me and asm, 'talent' is a very relative term!

I tell you though man, I'm loving C64 demos - some of the stuff those elite scene guys do on that machine are enough to make you fall off your chair - even doing things that the makers of the hardware would have thought were impossible, all the VIC tricks and things - superb.
pmc is offline  
Old 18 October 2008, 18:09   #15
musashi5150
move.w #$4489,$dff07e
 
musashi5150's Avatar
 
Join Date: Sep 2005
Location: Norfolk, UK
Age: 42
Posts: 2,351
Quote:
Originally Posted by pmc View Post
some of the stuff those elite scene guys do on that machine are enough to make you fall off your chair
Tell me about it! I have big respect for all the 64 sceners. Some amazing stuff on that little machine. They even remade Desert Dream for the 64... did you see that one?

http://www.pouet.net/prod.php?which=30213
musashi5150 is offline  
Old 18 October 2008, 18:19   #16
TCD
HOL/FTP busy bee
 
TCD's Avatar
 
Join Date: Sep 2006
Location: Germany
Age: 46
Posts: 31,522
Quote:
Originally Posted by musashi5150 View Post
Tell me about it! I have big respect for all the 64 sceners. Some amazing stuff on that little machine. They even remade Desert Dream for the 64... did you see that one?

http://www.pouet.net/prod.php?which=30213
That is Wow, I would never have thought that was possible on the C64. Big respect to the coders Thanks for the link musashi
TCD is offline  
Old 18 October 2008, 18:51   #17
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
Yeah I saw the Desert Dream remake, fantastic stuff on a C64 - top notch coding, graphics and music.

You should check out one of my personal favourites Tsunami from Booze Design, if you haven't already:

http://noname.c64.org/csdb/getinternalfile.php/6135/Tsunami.zip

I love that demo cos it flows so beautifully - it's so laid back and looks so effortless that while you're watching you forget how difficult that stuff is to do on a C64...
pmc is offline  
Old 02 November 2008, 21:04   #18
skurk
Registered User
 
Join Date: Sep 2008
Location: Trondheim, Norway
Posts: 12
Quote:
Originally Posted by pmc View Post
Totally the wrong forum really for a place where we should be talking about Amiga related coding but does anyone on here do any 6502 asm on C64? I've been trying to learn some over the last couple of days.
I've coded a couple of demos on the C64 recently. I'm using the ACME assembler, together with VICE. Once I have something that looks allright, I transfer the binary to the C64 with the MMC64, just to make sure that everything is A-OK (emulation is never 100% perfect)

Quote:
I've only done one routine so far - I knocked together a very quick and dirty scroll text routine which works (just about...) but the text scrolls too fast and I wanted to know if anyone knew of an elegant way to slow it down so it's readable...?
I'm guessing you scroll one character at the time? Slow it down by decreasing bits 2-0 in $d016. If you're stuck, just paste your code and I'll help.

For 6502 training, you can use the http://6502asm.com/ environment, it's a 6502 based virtual machine with development environment running in Javascript. I've heard the author of the site is super sexy and awsome in every thinkable way. hehe..
skurk is offline  
Old 04 November 2008, 09:55   #19
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
Quote:
I've coded a couple of demos on the C64 recently.
Cool. Any chance of posting them so we can see your stuff?

Quote:
I'm using the ACME assembler, together with VICE. Once I have something that looks allright, I transfer the binary to the C64 with the MMC64, just to make sure that everything is A-OK (emulation is never 100% perfect)
I've been using UltraEdit together with KickAssembler and VICE. I recently bought an old style bread box C64 and a 1541-Ultimate so I can test stuff out on the real thing too.

Quote:
I'm guessing you scroll one character at the time? Slow it down by decreasing bits 2-0 in $d016.
Yeah, I scroll one character at a time. I was always using $d016 - the reason it was going too fast was my lame code! I'd messed up on some loop logic but I found the problem and fixed it. Now I can read the scroller better.

Quote:
If you're stuck, just paste your code and I'll help.
Nice one skurk - if I need some help with anything I'm doing I might just take you up on that very kind offer.

I checked out 6502asm.com - nice site. You're right, whoever runs that site must be a bit of a hero...
pmc is offline  
Old 05 November 2008, 14:56   #20
skurk
Registered User
 
Join Date: Sep 2008
Location: Trondheim, Norway
Posts: 12
Quote:
Originally Posted by pmc View Post
Cool. Any chance of posting them so we can see your stuff?
Well, it's nothing worth mentioning actually. The last one was "Ledge and Deary" from the Solskogen party: http://noname.c64.org/csdb/release/?id=69056. I'm working on another multipart demo, but I'm not sure when/where it will be released yet.

Quote:
Nice one skurk - if I need some help with anything I'm doing I might just take you up on that very kind offer.
6502 assembly is just pure joy, so helping out is only fun

Quote:
I checked out 6502asm.com - nice site. You're right, whoever runs that site must be a bit of a hero...
Hehe. :-)
skurk is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual 6502 in JavaScript Charlie Retrogaming General Discussion 1 03 October 2010 13:35
for ASM programmers meynaf Coders. General 29 05 August 2010 10:00
Using ReadArgs() from asm oRBIT Coders. General 4 11 May 2010 16:11
The 6502 assembler code in "The Terminator" (1984) Shoonay Nostalgia & memories 2 15 May 2009 13:52
ASM Uni Course BippyM Coders. Tutorials 27 18 September 2008 10:37

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 00:44.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.09694 seconds with 13 queries