News: 11 March 2016 - Forum Rules

Author Topic: NES/6502 fixed-cycle delay code vending machine  (Read 2014 times)

Bisqwit

  • Sr. Member
  • ****
  • Posts: 424
  • Polite, but politically incorrect.
    • View Profile
    • http://iki.fi/bisqwit/
NES/6502 fixed-cycle delay code vending machine
« on: April 20, 2016, 12:00:01 pm »
Hello! I decided to share some code that I used in my Simon's Quest retranslation/improvement project.

This "vending machine" is a front-end to a generator, that generates a macro, that gives you the shortest possible instruction sequence on the NES CPU, for producing a specified amount of cycles of delay. I am using it in various situations for precisely-timed split-screen / scanline effects. Advantages over handwritten code include that the number of cycles to delay can be any compile-time numeric expression, as is needed in my project, where the number of splits & delays per screen can be large, especially with the map screen that is split into four slices, and the number of cycles to delay depends on various factors: The NTSC/PAL selection, and the mapper, as page-switches in each mapper consume a different number of cycles. Using generated code thus helps keep small not only the binary size, but the source code size as well.

http://bisqwit.iki.fi/utils/nesdelay.php

Please report to me if there are any problems with the vending machine or with the code it generates. Be sure to read the "Watch out for…" section of that page first.
« Last Edit: April 20, 2016, 01:32:13 pm by Bisqwit »

DackR

  • Full Member
  • ***
  • Posts: 130
  • Mo~
    • View Profile
    • Hackaday.io Page
Re: NES/6502 fixed-cycle delay code vending machine
« Reply #1 on: April 21, 2016, 12:47:34 am »
You, sir, are a god among men.

With love, me.