Jump to content

Search the Community

Showing results for tags 'math'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Commander X16 Forums
    • Introductions
    • X16 Discussion Lounge
    • X16 Help & Support Lounge
    • The Lounge
    • Hobbies and Interests

Categories

  • Official Software
  • Official Docs
  • Community Downloads
    • Games
    • Productivity Apps
    • Graphics Apps
    • Audio Apps
    • Demos
    • Networking Apps
    • Dev Tools
    • Tutorial Apps
    • Misc Apps

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


About Me

Found 21 results

  1. When programming in assembly language, quite often you will need to do calculations that would normally require floating point math. Those subroutines are available, the same ones that BASIC uses, but they are very slow. And if you're programming in assembly, you're doing so because it's much faster than BASIC, so using those routines can defeat the purpose, particularly if you need to do a lot of such calculations. Ideally in assembly language you want to have most of your variables consisting of single bytes, not the four used for floating point. It's having to move all those bytes around and doing calculations involving all of them that makes the floating point subroutines slow. And if you're going for speed, you can make a tradeoff: increased speed at the expense of accuracy. A function involving a single byte can just be a lookup table. Over the last several years I have developed a number of lookup tables and subroutines that enable some very fast math on the 6502 and now 65c02. Inspired by @svenvandevelde's question about ATAN2, I decided to compile many of them into a single 8kb file that can be loaded into banked RAM. I have other such routines and lookup tables, but I decided to just include those that would most likely be useful to the broadest range of applications. These lookup tables and functions will work on all revisions of the X16 emulator, and indeed will work on any 65c02 system as long as the file is loaded at $A000. The functions are all called through JMP redirects in page BF, and those JMP table locations will not change if I do revisions on the code. I'm pretty sure I killed all the bugs, but some might have slipped through. I'll be using further posts in this thread as sort of a user guide, but attached to this post is the file FASTMATH.BIN (the lookup tables and functions) and a text file containing the BASIC program that made all of the lookup tables (but don't copy and paste it into the emulator or it will overwrite FASTMATH.BIN). When using FASTMATH.BIN, you must use a relocated load to put it into banked RAM, otherwise it will load into memory at $7000 and won't work. Or you could load it into its default location at $7000 and just copy it up into the RAM bank of your choice. This software is released under an MIT license, meaning you can use it freely for any purpose, commercial or non-commercial, as long as you leave the MIT license in there (it's located at $BF7F). And please, these functions are all just approximations accurate to about 1%, so don't use the software for controlling a nuclear power plant or medical equipment. maketables.txt FASTMATH.BIN
  2. Version 2.0.0

    33 downloads

    When programming in assembly language, quite often you will need to do calculations that would normally require floating point math. Those subroutines are available, the same ones that BASIC uses, but they are very slow. And if you're programming in assembly, you're doing so because it's much faster than BASIC, so using those routines can defeat the purpose, particularly if you need to do a lot of such calculations. Ideally in assembly language you want to have most of your variables consisting of single bytes, not the five used for floating point. It's having to move all those bytes around and doing calculations involving all of them that makes the floating point subroutines slow. And if you're going for speed, you can make a tradeoff: increased speed at the expense of accuracy. A function involving a single byte can just be a lookup table. Over the last several years I have developed a number of lookup tables and subroutines that enable some very fast math on the 6502 and now 65c02. FASTMATH.BIN is many of them compiled into a single 8kb file that can be loaded into banked RAM. These lookup tables and functions will work on all revisions of the X16 emulator, and indeed will work on any 65c02 system as long as the file is loaded at $A000. The functions are all called through JMP redirects in page BF, and those JMP table locations will not change if I do revisions on the code. I'm pretty sure I killed all the bugs, but some might have slipped through. This is probably going to be the final revision of FASTMATH, barring some sneaky bug hiding in the code. There's only 6 bytes left anyhow. The file fastmath.txt contains detailed information about each lookup table and function and how to use them. The file FASTMATH.BIN is the binary that must be loaded into banked RAM.
  3. FASTMATH View File When programming in assembly language, quite often you will need to do calculations that would normally require floating point math. Those subroutines are available, the same ones that BASIC uses, but they are very slow. And if you're programming in assembly, you're doing so because it's much faster than BASIC, so using those routines can defeat the purpose, particularly if you need to do a lot of such calculations. Ideally in assembly language you want to have most of your variables consisting of single bytes, not the five used for floating point. It's having to move all those bytes around and doing calculations involving all of them that makes the floating point subroutines slow. And if you're going for speed, you can make a tradeoff: increased speed at the expense of accuracy. A function involving a single byte can just be a lookup table. Over the last several years I have developed a number of lookup tables and subroutines that enable some very fast math on the 6502 and now 65c02. FASTMATH.BIN is many of them compiled into a single 8kb file that can be loaded into banked RAM. These lookup tables and functions will work on all revisions of the X16 emulator, and indeed will work on any 65c02 system as long as the file is loaded at $A000. The functions are all called through JMP redirects in page BF, and those JMP table locations will not change if I do revisions on the code. I'm pretty sure I killed all the bugs, but some might have slipped through. This is probably going to be the final revision of FASTMATH, barring some sneaky bug hiding in the code. There's only 6 bytes left anyhow. The file fastmath.txt contains detailed information about each lookup table and function and how to use them. The file FASTMATH.BIN is the binary that must be loaded into banked RAM. Submitter Ed Minchau Submitted 06/23/22 Category Productivity Apps  
  4. mobluse

    Aritm

    Version 0.3.5

    64 downloads

    Aritm is a game that trains you in mental calculation. It only teaches what is necessary to know in order to calculate manually using pen and paper. It adapts and asks more about what you answered wrong before. Aritm is written in pure Commander X16 BASIC v2 and uses X16 control codes for text and screen colors, and has sound effects. Future versions will probably support larger text in game. Aritm is available for many platforms including graphing calculators, Java phones, spread sheets, and common retro computers. You can run using the "Try it now" button or from command line: x16emu -prg ARITM-X16.PRG -run -echo If you exit the program you can LIST it and copy the listing to an editor. Aritm is open source (GPLv3) and is tested using an automatic testing system: https://github.com/mobluse/aritmjs
  5. As you know, I'm working on this game engine. One of the missing parts in the engine is to quickly calculate the angle between two points on the plane. In my gaming logic, I'm already able to calculate the deltas for X and Y based on a given angle, using sin and cosin tables, but my biggest hurtle was to understand how to find the right way to make an enemy shoot a bullet from his machine to the player machine with a relevant accuracy (but not too accurate)... That brought me to the topic of the arctan2 function, of which a lot is written. Every programming language imaginable has this function implemented. However ... that did not solve my issue for the CX16. How to quickly calculate a usable angle from two points on a plane on an 8 bit machine, where multiplication and division takes CPU time. So I've been seaching the internet for a solution (I am not a matematician but learned sufficient maths in my studies, but forgot most of it). Then one day, I stumbled on these two algorithms: - Z80 CPU architecture - 8-bit atan2 | MSX Resource Center (Page 1/3) - 6502 CPU architecture - base:8bit_atan2_8-bit_angle [Codebase 64 wiki] The latter drew my immediate interest, and the more I started to analyze the assembly code, the less I understood what was going on... ;; Calculate the angle, in a 256-degree circle, between two points. ;; The trick is to use logarithmic division to get the y/x ratio and ;; integrate the power function into the atan table. Some branching is ;; avoided by using a table to adjust for the octants. ;; In otherwords nothing new or particularily clever but nevertheless ;; quite useful. ;; ;; by Johan Forslöf (doynax) octant = $fb ;; temporary zeropage variable atan2 lda x1 sbc x2 bcs *+4 eor #$ff tax rol octant lda y1 sbc y2 bcs *+4 eor #$ff tay rol octant lda log2_tab,x sbc log2_tab,y bcc *+4 eor #$ff tax lda octant rol and #%111 tay lda atan_tab,x eor octant_adjust,y rts This routine seems not to be a blast from the past, as it appears to be posted in 2015 somewhere on the site. However, the way how the angle is calculated is rather genius ... (Although the creator is saying it's nothing special ..., I admire the intellect behind this). So I decided to study it a bit more in depth what is going on here ... The routine accepts two 8 bit 2D coordinates, so an (x1,y1) and (x2,y2), and calculates an "angle" between 0 and 255! It first calculates the "slope" between the two points. As we all know, to calculate a slope, one needs to "divide the y over x" (or the other way around), and executing a division on an 8-bit machine requires a proprietary algorithm to be written with the risk of consuming too much CPU. However, what this algorithm does, is uses a base 2 logarithm table that applies the Logarithm quotient rule: In other words, using the logarithm table, it is very fast to calculate the quotient of the X/Y by subtracting the logarithm of X over the logarithm of Y. lda log2_tab,x sbc log2_tab,y The other concept that the atan2 routine implements, is the angle calculation over 8 "octants" in a circle (there are 4 quadrants in a circle) ... It does this by examining 3 essential parameters of the input: the sign of the x and y coordinates, and then when x is divided over y, to determine if x is greater than y or vise versa. This takes most of the code, and instead of writing a lot of branches, the logic implements the selection of the octant segment using an assembler trick using the carry flag! octant = $fb ;; temporary zeropage variable The logic builds up the octant variable gradually, which essentially contains the results of the carry flag shifted to the left at each of the calculation steps. First, the absolute value of x is determined, and the corresponding segments in the octant model is determined, whether x1 is smaller than x2. When x1 is smaller than x2, then the carry will be set and will be shifted into the octant variable! So if x1 < x2, then the carry will be set, and the eor #$ff will make the negative result "positive", but it seems not to do this using the 2s complement rule (eor $#ff, clc, adc $#01). I think he did not implement 2s complement because the logic anyway achieves an approximation, and 2nd the carry bit would be cleared when clc would be used for the octant determination ... Anyway, the octant variable will get a value %1 or %0 at this stage..., depending on the value of x1 and x2. atan2 lda x1 sbc x2 bcs *+4 eor #$ff tax rol octant Second, the absolute value of y is determined, and the corresponding segment in the octant model, whether y1 is smaller than y2. The resulting carry is left shifted into the octant variable, but bare in mind that the octant has already the octant segments of the x value embedded! So the octant values now will get a value %00, %01, %10 or %11, depending on the value of y1 and y2. Thus the quadrant in the octant model is calculated here. lda y1 sbc y2 bcs *+4 eor #$ff tay rol octant Third, the logaritmic devision is applied (as explained above) but also here the 3rd dimension in the octant model is determined, depending whether x is smaller than y. So the octant now can get value %000, %001, %010, %011, %100, %101, %110 or %111, and the resulting octant segment now is fully calculated. lda log2_tab,x sbc log2_tab,y bcc *+4 eor #$ff tax lda octant rol and #%111 tay Note that the x register will contain the position to calculate the angle using the arctan table, and the y register will contain the 3 bit index to adjust the calculated 5-bit angle with the resulting octant segment! The octant variable now has 8 possible values to calculate the angle, based on the calculated angle containing out of 5 bits in the 8-bit range using the arctan table ... Depending on the resulting value: octant_adjust .byte %00111111 ;; x+,y+,|x|>|y| .byte %00000000 ;; x+,y+,|x|<|y| .byte %11000000 ;; x+,y-,|x|>|y| .byte %11111111 ;; x+,y-,|x|<|y| .byte %01000000 ;; x-,y+,|x|>|y| .byte %01111111 ;; x-,y+,|x|<|y| .byte %10111111 ;; x-,y-,|x|>|y| .byte %10000000 ;; x-,y-,|x|<|y| The last point to be explained is how the angle is calculated ... this is done using the pre-defined arctan table. The author does a trick, as the arctan table normally has a domain -pi/2 < y < pi/2, the atan table has the values populated in exponential order base 2 in 5 bits, but only from the lower domain (-pi/2 < y), excluding the value x = 0! In other words, it models a table of the values between x = -256 and x = -1 where the arctan table is populated with the expondential results of arctan(2^(x/32))*128/pi. A closer look will quickly identify that 128 is actually a simplification of 256/(pi*2) ... Thus, the resulting table contains values from $00 till $1f, which calculates the angle for octant segment 0. Again, $20 is not included as this would be the starting value of octant 1. The atan table actually models the resulting angle of the first segment in the octant model. The octant variable then will adjust the resulting angle to the correct octant depending on x1 - x2 values, y1 - y2 value and the resulting x and y value comparison. I've modelled this out in geogebra, as part of the study, to fully understand what the arctan function is doing and how the angle is calculated for the first octant segment! See attached, but here is how the geogebra model looks like. Note that the functions implement the "floor()" method to eliminate any fractional number and to simulate how it would run on the 8 bit machine ... The green liine models the logarithm function log2(x)*scale, which is set in this example to 32. The blue line is the actan function arctan(2^(x/scale))*width/(pi*2), with a width set to 256. This will result in angles between 0 and 63 for two octant segments 0 and 1. Point A and B are the two points for which the atan is calculated. Move A and/or B but the function only implements the arctan, not the arctan2! The geogebra model explains that when the AT point is in the lower domain of the arctan function, it returns the angle of point B from 0 to 31 degrees. Now, I find that an angle of 256 possible values is too much, so my game logic implements and angle of 64 angle values, and that is more than enough! So, the actual octant model would be a subdivision of 3 bits instead of 5 bits, from 0 to 7. Other point is the "resulution", it is not necessary to store for the log2 table 256 values, as the only thing I'm trying to accomplish, is to find the angle, and i can downsize the resolution from 640x480 to 160x120 for example. (by shifting the bits with 2 positions to the right), which requires me to only populate a table of 160 bytes ..., This would result in geogebra in the following settings (see the sliders) and the resulting angle). A scale of 16 and a width of 64 would allow me to only require 64 records in the arctan table, and 160 records in the log2 table, to calculate the angle between 0 and 7. I'm still studying a bit on how to optimize this and to actually implement all this in a working CX16 atan2 function, but i'll put that in a later post (as I'm progressing) ... Otherwise it becomes too much to write it all down ... I'm not a mathematician, so not sure if the above explanation makes sense and any adjustment, recommendation or addtional info you want to share is welcome in this very interesting topic. I'm sure there are people here who have been doing this in the past already ... Sven ATAN2.ggb
  6. Version 0.6

    689 downloads

    Here is the Mandelbrot version of my Julia Set program, coded in assembly. Again, many thanks to the forum users here for their guidance, as well as the many YouTubers with their excellent tutorials on 6502 assembly language. It's a lot faster than the BASIC version, but nevertheless, benefits from being run in warp mode. Now in colour, with thanks to: VERA Overview (8bitcoding.com) NEW VERSION NOW WITH MOUSE CONTROLS! When the image has finished rendering, click the left mouse on the area of the screen you wish to zoom in to. To change the detail settings (cycle between Low, Med, High) click the right mouse button. Poke around in the old version... Try copying and pasting the following groups of POKEs to explore further (not all at once, just each paragraph in turn!): POKE $D6B,$19:POKE $D6A,$64:REM FX=6500 POKE $D6D,$13:POKE $D6C,$54:REM FY=4948 POKE $D6E,$00:POKE $D6F,$FF:REM FX=POS,FY=NEG POKE $D7B,$00:POKE $D7A,$01:REM STEP=1 POKE $D7C,$FF:REM ITERATIONS=255 SYS2061 POKE $D6B,$0F:POKE $D6A,$A0:REM FX=4000 POKE $D6D,$00:POKE $D6C,$00:REM FY=0 POKE $D6E,$FF:POKE $D6F,$FF:REM FX=NEG,FY=NEG POKE $D7B,$01:POKE $D7A,$F4:REM STEP=500 POKE $D7C,$FF:REM ITERATIONS=255 SYS2061 POKE $D6B,$0F:POKE $D6A,$878:REM FX=3960 POKE $D6D,$03:POKE $D6C,$E8:REM FY=1000 POKE $D6E,$FF:POKE $D6F,$FF:REM FX=NEG,FY=NEG POKE $D7B,$00:POKE $D7A,$32:REM STEP=50 POKE $D7C,$FF:REM ITERATIONS=255 SYS2061 To use the POKES above in the web emulator, first click the X in the top right corner of the web emulator. Paste the POKES above that you want to use in to the text field to the left, replacing what's already in there, then click the Run button. Individual addresses that can be poked: $D6A 30 75 .word 30000 ; FX $D6C A8 61 .word 25000 ; FY $D6E FF .byte $ff ; FX SIGN ff = negative $D6F FF .byte $ff ; FY SIGN ff = negative $D7A A8 61 .word 25000 ; STEP (lower=higher zoom) $D7C 10 .byte $10 ; ITERATIONS Old poke codes for the colour PETSCII version: step: POKE $0D3D e.g. 50 for a step of 0.05 (smaller number, higher zoom) iterations: POKE $0D3F e.g. 30 iterations about right, higher = slower start x: POKE $0D2F, normally 8 (for -0.8) - nicely centred at low zoom start y: POKE $0D31, normally 12 (for -1.2) - again centred at low zoom Old poke codes for the PETSCII version: step: POKE $0cff e.g. 50 for a step of 0.05 (smaller number, higher zoom) iterations: POKE $0d01 e.g. 30 iterations about right, higher = slower start x: POKE $0cf1, normally 8 (for -0.8) - nicely centred at low zoom start y: POKE $0cf3, normally 12 (for -1.2) - again centred at low zoom You Tube video of this in action: Commander X16 - 6502 assembly demo - Mandelbrot set - YouTube Commander X16 - Fractal Zoom Demo - 6502 Assembly - YouTube
  7. Version 0.0.4

    158 downloads

    This is a quick demo of a 2D graphics library I've been working on recently. It's written in assembler, and aims to make life a bit easier when it comes to drawing vector graphics. You can define individual polygons which can be moved about and rotated. The source code looks fairly daunting, but when it comes down to it, building, transforming and rendering the polygons is very straightforward. Hopefully this will form the basis of a game at some point soon. (Perhaps an Asteroids clone?) Once I sink my teeth into interrupt handling, I should be able to "vsync" everything so it's flicker-free. All comments and suggestions welcome! Short screen capture of this demo on YouTube (featuring my tunez!!): Commander X16 Demo - Vector Graphics in 6502 Assembly - YouTube WARNING: For those who are sensitive to flickering/strobing, please be aware that this may cause problems for you. -- See below for a quick preview of the game I'm working on, retro flickering and all!
  8. Assembly Vector Graphics Demo View File This is a quick demo of a 2D graphics library I've been working on recently. It's written in assembler, and aims to make life a bit easier when it comes to drawing vector graphics. You can define individual polygons which can be moved about and rotated. The source code looks fairly daunting, but when it comes down to it, building, transforming and rendering the polygons is very straightforward. Hopefully this will form the basis of a game at some point soon. (Perhaps an Asteroids clone?) Once I sink my teeth into interrupt handling, I should be able to "vsync" everything so it's flicker-free. All comments and suggestions welcome! Short screen capture of this demo on YouTube (featuring my tunez!!): Commander X16 Demo - Vector Graphics in 6502 Assembly - YouTube WARNING: For those who are sensitive to flickering/strobing, please be aware that this may cause problems for you. -- See below for a quick preview of the game I'm working on, retro flickering and all! Submitter gavinhaslehurst Submitted 02/03/21 Category Demos  
  9. Mandelbrot Assembly Demo View File Here is the Mandelbrot version of my Julia Set program, coded in assembly. Again, many thanks to the forum users here for their guidance, as well as the many YouTubers with their excellent tutorials on 6502 assembly language. It's a lot faster than the BASIC version, but nevertheless, benefits from being run in warp mode. Now in colour, with thanks to: VERA Overview (8bitcoding.com) NEW VERSION NOW WITH MOUSE CONTROLS! When the image has finished rendering, click the left mouse on the area of the screen you wish to zoom in to. To change the detail settings (cycle between Low, Med, High) click the right mouse button. Poke around in the old version... Try copying and pasting the following groups of POKEs to explore further (not all at once, just each paragraph in turn!): POKE $D6B,$19:POKE $D6A,$64:REM FX=6500 POKE $D6D,$13:POKE $D6C,$54:REM FY=4948 POKE $D6E,$00:POKE $D6F,$FF:REM FX=POS,FY=NEG POKE $D7B,$00:POKE $D7A,$01:REM STEP=1 POKE $D7C,$FF:REM ITERATIONS=255 SYS2061 POKE $D6B,$0F:POKE $D6A,$A0:REM FX=4000 POKE $D6D,$00:POKE $D6C,$00:REM FY=0 POKE $D6E,$FF:POKE $D6F,$FF:REM FX=NEG,FY=NEG POKE $D7B,$01:POKE $D7A,$F4:REM STEP=500 POKE $D7C,$FF:REM ITERATIONS=255 SYS2061 POKE $D6B,$0F:POKE $D6A,$878:REM FX=3960 POKE $D6D,$03:POKE $D6C,$E8:REM FY=1000 POKE $D6E,$FF:POKE $D6F,$FF:REM FX=NEG,FY=NEG POKE $D7B,$00:POKE $D7A,$32:REM STEP=50 POKE $D7C,$FF:REM ITERATIONS=255 SYS2061 To use the POKES above in the web emulator, first click the X in the top right corner of the web emulator. Paste the POKES above that you want to use in to the text field to the left, replacing what's already in there, then click the Run button. Individual addresses that can be poked: $D6A 30 75 .word 30000 ; FX $D6C A8 61 .word 25000 ; FY $D6E FF .byte $ff ; FX SIGN ff = negative $D6F FF .byte $ff ; FY SIGN ff = negative $D7A A8 61 .word 25000 ; STEP (lower=higher zoom) $D7C 10 .byte $10 ; ITERATIONS Old poke codes for the colour PETSCII version: step: POKE $0D3D e.g. 50 for a step of 0.05 (smaller number, higher zoom) iterations: POKE $0D3F e.g. 30 iterations about right, higher = slower start x: POKE $0D2F, normally 8 (for -0.8) - nicely centred at low zoom start y: POKE $0D31, normally 12 (for -1.2) - again centred at low zoom Old poke codes for the PETSCII version: step: POKE $0cff e.g. 50 for a step of 0.05 (smaller number, higher zoom) iterations: POKE $0d01 e.g. 30 iterations about right, higher = slower start x: POKE $0cf1, normally 8 (for -0.8) - nicely centred at low zoom start y: POKE $0cf3, normally 12 (for -1.2) - again centred at low zoom You Tube video of this in action: Commander X16 - 6502 assembly demo - Mandelbrot set - YouTube Commander X16 - Fractal Zoom Demo - 6502 Assembly - YouTube Submitter gavinhaslehurst Submitted 01/17/21 Category Demos  
  10. Version 0.0.1

    49 downloads

    Here is my work in progress Julia Set demo! I wrote this in BASIC a couple of weeks ago when starting out on the Commander X16 journey. Since then, I have been trying to learn 6502 assembler. This is the result so far! After wrestling with floating point arithmetic (see my other posts!) I have finally managed to get something working. At the moment, the output is PETSCII, but all being well there will be a graphical version of this in the pipeline. Feel free to muck about with the code. It's probably not written very well, but I have only been doing this for a couple of weeks (and despite being badly written, it's much faster than the BASIC version!) Many thanks to all the experienced forum users who commented on my previous posts to help guide me through this process, as well as the many YouTubers who posted tutorials about how to program the 6502. Watch this space for updates! Some things you can poke around in to change the parameters: POKE $0D30, X -- change the REAL component (this is passed as an integer but can be divided by ten a number of times to achieve smaller numbers - see below) POKE $0D36, X -- the number of times to divide the REAL component by 10 (in order to get around the lack of FIN in the Kernal at present) POKE $0D34, $00 -- make the REAL component positive POKE $0D34, $FF -- make the REAL component negative POKE $0D32, X -- change the IMAG component (this is passed as an integer but can be divided by ten a number of times to achieve smaller numbers - see below) POKE $0D37, X -- the number of times to divide the IMAG component by 10 (in order to get around the lack of FIN in the Kernal at present) POKE $0D35, $00 -- make the IMAG component positive POKE $0D35, $FF -- make the IMAG component negative
  11. Floating Point in 6502 View File **EDITED TO ADD: for all those who are new like me, exploring this world, please see the forum thread where some of the more experienced coders here have pointed out some really useful Kernal routines which take the pain out of this!! Hi all! As I journey towards 6502 mastery (LOL), this demo explores floating point numbers and how they are stored and managed in binary. It borrows heavily from others' code to achieve what I was struggling to do from first principles, and I am grateful to all the YouTubers, bloggers and hobbyists out there who have kindly shared their work in this area. This particular routine takes a binary floating point number stored in memory and displays it on the screen in a human-readable decimal format. It also dumps some of the memory addresses involved so you can have a look under the hood. Some functions include: jsr FLTTODEC Displays the floating point number stored in MSB, NMSB, NLSB, LSB and BEXP as a decimal number on screen (PETSCII string) jsr print_mem_16 .word (addr) Memory dump. Shows paired bytes at the address, looping for MemDumpLen addresses (default=8) If you click try it now, you can poke around in memory to change the starting parameters of the programme. For example, to change the most significant byte of the mantissa, POKE $080E,XX and to change the binary exponent, POKE $081E,XX then type RUN again to see the results. FLTTODEC was adapted by me for the specific hardware of the Commander X16 from Jeff Tranter's code, who in turn adapted it for CC65 from the original appearing in Compute! issues 9 and 11, 1981 by Marvin L. De Jong. https://github.com/jefftranter/6502/blob/master/asm/wozfp/bcdfloat.s Jeff's Blog: https://jefftranter.blogspot.com/ Submitter gavinhaslehurst Submitted 01/14/21 Category Demos  
  12. Julia Set Assembly Demo View File Here is my work in progress Julia Set demo! I wrote this in BASIC a couple of weeks ago when starting out on the Commander X16 journey. Since then, I have been trying to learn 6502 assembler. This is the result so far! After wrestling with floating point arithmetic (see my other posts!) I have finally managed to get something working. At the moment, the output is PETSCII, but all being well there will be a graphical version of this in the pipeline. Feel free to muck about with the code. It's probably not written very well, but I have only been doing this for a couple of weeks (and despite being badly written, it's much faster than the BASIC version!) Many thanks to all the experienced forum users who commented on my previous posts to help guide me through this process, as well as the many YouTubers who posted tutorials about how to program the 6502. Watch this space for updates! Some things you can poke around in to change the parameters: POKE $0D30, X -- change the REAL component (this is passed as an integer but can be divided by ten a number of times to achieve smaller numbers - see below) POKE $0D36, X -- the number of times to divide the REAL component by 10 (in order to get around the lack of FIN in the Kernal at present) POKE $0D34, $00 -- make the REAL component positive POKE $0D34, $FF -- make the REAL component negative POKE $0D32, X -- change the IMAG component (this is passed as an integer but can be divided by ten a number of times to achieve smaller numbers - see below) POKE $0D37, X -- the number of times to divide the IMAG component by 10 (in order to get around the lack of FIN in the Kernal at present) POKE $0D35, $00 -- make the IMAG component positive POKE $0D35, $FF -- make the IMAG component negative Submitter gavinhaslehurst Submitted 01/17/21 Category Demos  
  13. Version 0.0.2

    38 downloads

    **EDITED TO ADD: for all those who are new like me, exploring this world, please see the forum thread where some of the more experienced coders here have pointed out some really useful Kernal routines which take the pain out of this!! Hi all! As I journey towards 6502 mastery (LOL), this demo explores floating point numbers and how they are stored and managed in binary. It borrows heavily from others' code to achieve what I was struggling to do from first principles, and I am grateful to all the YouTubers, bloggers and hobbyists out there who have kindly shared their work in this area. This particular routine takes a binary floating point number stored in memory and displays it on the screen in a human-readable decimal format. It also dumps some of the memory addresses involved so you can have a look under the hood. Some functions include: jsr FLTTODEC Displays the floating point number stored in MSB, NMSB, NLSB, LSB and BEXP as a decimal number on screen (PETSCII string) jsr print_mem_16 .word (addr) Memory dump. Shows paired bytes at the address, looping for MemDumpLen addresses (default=8) If you click try it now, you can poke around in memory to change the starting parameters of the programme. For example, to change the most significant byte of the mantissa, POKE $080E,XX and to change the binary exponent, POKE $081E,XX then type RUN again to see the results. FLTTODEC was adapted by me for the specific hardware of the Commander X16 from Jeff Tranter's code, who in turn adapted it for CC65 from the original appearing in Compute! issues 9 and 11, 1981 by Marvin L. De Jong. https://github.com/jefftranter/6502/blob/master/asm/wozfp/bcdfloat.s Jeff's Blog: https://jefftranter.blogspot.com/
  14. Version 0.0.4

    266 downloads

    *** THIS FILE IS ALSO NOW IN THE DEMO SECTION TO ENABLE THE "TRY IT NOW" FEATURE *** This may be of interest to absolute 6502 assembly beginners like me, although advanced 6502 programmers may cringe at the way I've done things here! This program does very little, but it is a repository of useful assembly routines for things like printing different bytes of memory (useful for debugging) as well as some basic math operations. I will keep adding to this as I progress through my assembly journey (I'm aiming to write my fractal BASIC programs in assembly). Thanks to the following YouTubers for their excellent tutorials on all things 6502: Ben Eater - YouTube Matt Heffernan - YouTube ChibiAkumas - YouTube (and also his excellent website: Assembly Tutorials: Learn 6502 Assembly Programming... With ChibiAkumas!) Function usage: (notation for cc65 assembler) jsr print .byte (list of PETSCII character codes to print, ending in a $0 byte) jsr println .byte (list of PETSCII character codes to print, ending in a $0 byte) jsr print_mem .word (start address of memory dump) Set MEMDUMPLEN to the number of addresses you wish print_mem to display.
  15. Version 0.0.4

    167 downloads

    This may be of interest to absolute 6502 assembly beginners like me, although advanced 6502 programmers may cringe at the way I've done things here! This program does very little, but it is a repository of useful assembly routines for things like printing different bytes of memory (useful for debugging) as well as some basic math operations. I will keep adding to this as I progress through my assembly journey (I'm aiming to write my fractal BASIC programs in assembly). Thanks to the following YouTubers for their excellent tutorials on all things 6502: Ben Eater - YouTube Matt Heffernan - YouTube ChibiAkumas - YouTube (and also his excellent website: Assembly Tutorials: Learn 6502 Assembly Programming... With ChibiAkumas!) Function usage: (notation for cc65 assembler) jsr print .byte (list of PETSCII character codes to print, ending in a $0 byte) jsr println .byte (list of PETSCII character codes to print, ending in a $0 byte) jsr print_mem .word (start address of memory dump) Set MEMDUMPLEN to the number of addresses you wish print_mem to display.
  16. Beginner 6502 Assembly Stuff View File This may be of interest to absolute 6502 assembly beginners like me, although advanced 6502 programmers may cringe at the way I've done things here! This program does very little, but it is a repository of useful assembly routines for things like printing different bytes of memory (useful for debugging) as well as some basic math operations. I will keep adding to this as I progress through my assembly journey (I'm aiming to write my fractal BASIC programs in assembly). Thanks to the following YouTubers for their excellent tutorials on all things 6502: Ben Eater - YouTube Matt Heffernan - YouTube ChibiAkumas - YouTube (and also his excellent website: Assembly Tutorials: Learn 6502 Assembly Programming... With ChibiAkumas!) Function usage: (notation for cc65 assembler) jsr print .byte (list of PETSCII character codes to print, ending in a $0 byte) jsr println .byte (list of PETSCII character codes to print, ending in a $0 byte) jsr print_mem .word (start address of memory dump) Set MEMDUMPLEN to the number of addresses you wish print_mem to display. Submitter gavinhaslehurst Submitted 01/12/21 Category Demos  
  17. Julia Set Demo View File This is a quick and dirty Julia set demo written in Commander X16 BASIC. It generates a random Julia set each time it is run. I strongly suggest using the emulator's -warp option to speed things up a bit! Enjoy the fractal action! Submitter gavinhaslehurst Submitted 01/07/21 Category Demos  
  18. Version 0.0.1

    27 downloads

    This is a quick and dirty Julia set demo written in Commander X16 BASIC. It generates a random Julia set each time it is run. I strongly suggest using the emulator's -warp option to speed things up a bit! Enjoy the fractal action!
  19. Version 0.0.2

    61 downloads

    This is a quick and dirty Mandelbrot set demo written in Commander X16 BASIC. I strongly suggest using the emulator's -warp option to speed things up a bit! I plan to make this a bit more user friendly, and include more options for zooming, changing colours etc. But for now, enjoy the fractal action!
  20. Mandelbrot Basic Demo View File This is a quick and dirty Mandelbrot set demo written in Commander X16 BASIC. I strongly suggest using the emulator's -warp option to speed things up a bit! I plan to make this a bit more user friendly, and include more options for zooming, changing colours etc. But for now, enjoy the fractal action! Submitter gavinhaslehurst Submitted 01/07/21 Category Demos  
  21. Aritm View File Aritm is a game that trains you in mental calculation. It only teaches what is necessary to know in order to calculate manually using pen and paper. It adapts and asks more about what you answered wrong before. Aritm is written in pure Commander X16 BASIC v2 and uses X16 control codes for text and screen colors, and has sound effects. Future versions will probably support larger text in game. Aritm is available for many platforms including graphing calculators, Java phones, spread sheets, and common retro computers. You can run using the "Try it now" button or from command line: x16emu -prg ARITM-X16.PRG -run -echo If you exit the program you can LIST it and copy the listing to an editor. Aritm is open source (GPLv3) and is tested using an automatic testing system: https://github.com/mobluse/aritmjs Submitter mobluse Submitted 09/12/20 Category Games  
×
×
  • Create New...

Important Information

Please review our Terms of Use