Jump to content

DusanStrakl

Members
  • Content Count

    90
  • Joined

  • Last visited

  • Days Won

    4

Posts posted by DusanStrakl


  1. 4 minutes ago, Wertzui said:

    @DusanStrakl So that's what I was doing wrong. When I first tried VPOKEs, I didn't write it in the proper format, and wondered why it gives me "illegal quantity error"-s.

    Yeah, I am playing with X16 Emulator for more than a year and still mix them up occasionally 🙂

    Actually I saw so many questions about this I just started writing another post for my blog to explain how to use PSG in BASIC.


  2. I think you are overcomplicating a bit. You don't need to program VERA registers when using BASIC, you can use VPOKE to write data to VRAM directly and let BASIC interpreter deal with VERA registers.

    A simple program to turn on square wave (pulse) and increases frequency can be written as below:

    10 VPOKE 1,$F9C3,%00111111:REM     SET WAVEFORM FOR VOICE 0
    20 VPOKE 1,$F9C2,%11111111:REM     SET LEFT AND RIGHT CHANNEL AT MAX VOLUME
    30 FOR N=200 TO 2000 STEP 5
    40 VPOKE 1,$F9C1,INT(N/256):REM    SET HIGH BYTE OF FREQUENCY
    50 VPOKE 1,$F9C0,N AND 255:REM     SET LOW BYTE OF FREQUENCY
    60 FOR I=1 TO 200:NEXT I:REM       DELAY
    70 NEXT N
    80 VPOKE 1,$F9C0,0:VPOKE 1,$F9C1,0

     

     

     

    • Like 1

  3. Agree with Matt, VERA PSG is way to get started. I implemented very simple, rudimentary sounds in my version of Tetris in BASIC:

    https://www.8bitcoding.com/p/crazy-tetrominoes.html

    If you don't want to deal with programming you can also just import and call four basic sounds in my Simplest Sound Effects Library for BASIC:

    https://www.8bitcoding.com/p/simplest-sound-effects-library-for.html

     

    Later if you want to add music that plays independently in the background of BASIC program you can opt to a bit more complex Music Library:

    https://www.8bitcoding.com/p/music-player-library-for-basic-programs.html

    • Like 1

  4. 12 hours ago, Lucky Phil said:

    Terrific stuff... very nicely done! From a novice point of view, it's great to see what can still be achieved in BASIC - without diving head-first into assembly language. I guess that the relatively fast clock rate and sophisticated code (as opposed to what were on offer in the beloved, original Commodore 64) negate many of the arguments against developing in BASIC, after all?

    Thanks Lucky Phil. I agree, Commodore BASIC is not ideal language but then again there is no such thing anyway. I find it very convenient to tinker with, prototype and with some effort and clever coding a lot of fun results can be achieved.

    • Like 1

  5. 12 hours ago, Jakebullet70 said:

    This is real good stuff. Sometimes I think people forget this is still a BASIC machine.

     

    Thanks Jake. I agree and with powerful hardware supported graphics and 8Mhz clock speed a lot can be done in BASIC. I am working mostly on my Assembly tutorials now but I am sure I will add some more BASIC tutorials and games soon.

    • Thanks 1

  6. This has been a common question for a while now and Stefan explained it perfectly. There are several other keys that can't be detected by standard Kernal routine at this time and I was assured that all the keys on the keyboard will have function in the future. I expect they will also fix some discrepancies like for example not use F4 to switch between 40/80 display when there is a dedicated button for it etc.


  7. When I was working on something reusable for my needs I was always struggling with really how generic such a library can and should be. I can think of few dilemmas from the top of my head:

    Do I support default screen size only or make it generic, specifically Map width is tricky one because if you want to support anything else than 128 tile width the VERA MID parameter is no longer Y dimension and require more checks and bit shifting.

    How to handle colors, do I go for standard predefined colors for different objects/widgets or should they always be passed as parameters. If second what happens if you want to draw e.g. frame parts in different colors to represent highlights etc.

    Do I allow different variations e.g. can frame be with rounded corners or square corners or perhaps the whole frame can be built with full or half blocks or even custom characters.

    Support for Lower case / Upper case PETSCI / ISO and then translations to screen codes

    Before mentioned number to text translations

    etc.

     

    This can lead to a real rabbit hole of options so I suggest not to overthink and to really simplify the first version and only support default screen and very basic functionality and then see where it leads.

    • Like 1
    • Thanks 1

  8. Yup had the same problem when I wrote music library for BASIC programs. Of course I had to back up registers because I had to allow the default IRQ handler to take over after I was done playing with PSG (pun intended 🙂 ) and of course BASIC programs print, draw, scroll, etc.


  9. 18 hours ago, kelli217 said:

    Ctrl and Alt are arranged horizontally on my keyboard, so playing the left side took a bit of adjustment. 🙂

    Yeah it is not ideal but it is compromise that works reasonably well.. I don't think anybody uses real joysticks with emulator and we still don't have proper access to keyboard to programmatically detect key presses and not rely on kernal. Of course for this type of game analog input would be the best.

    • Like 1

  10. Crazy Pong

    View File

    After three tutorials on how to use Sprites on Commander X16 using Assembly, I wrote a game to demonstrate all we learned there plus of course some necessary techniques like reading controls, using interrupts and utilizing Fixed Point Notation.

    Full tutorial with source code walkthrough is available on my blog:

    https://www.8bitcoding.com/p/crazy-pong.html

     


     

    • Like 3

  11. 1 hour ago, Ed Minchau said:

    The original Quake was 320x200 pixels.  I've been looking into the math behind representing the range [-1..1] as 1+7 bit numbers; it's a two's complement notation divided by 127.  So far using ~8kb of lookup tables I've got fixed-point multiplication, division, sin/cos/arcsin/arctan, and a very fast 1/sqrt(x^2+y^2+z^2) normalization function, just four lookups and two additions then three multiplications or divisions, faster than the normalization function Quake used, albeit 8 bit instead of floating point.  I'm giving serious thought to making an 8bit 3D game engine.

    Go for it, it would be very interesting to see what kind of performance you could get out of it.


  12. VERA PSG is definitely not as powerful as SID. Like mentioned before, there are no hardware supported ADSR envelopes and no filters.

    I wrote a music player with software envelope support that can be called from BASIC programs (and of course also from assembly or C) with some predefined envelopes and ability to test your own. I also wrote stripped down version with four simple sound effects for BASIC programs. I use standard VSYNC interrupt to update the envelope so it can only be adjusted 60 times per second. They both come with source code if you want to tinker with it.

    Music Player:

    https://www.8bitcoding.com/p/music-player-library-for-basic-programs.html

    Sound Effects:

    https://www.8bitcoding.com/p/simplest-sound-effects-library-for.html

    • Like 3

  13. I wrote a series of blog posts/articles on Commander X16 architecture and coding. I have started with focus on beginners and then slowly moved to more advanced topics and techniques. First I tackle smaller chunks and use simple examples to show the topic in practice.

    After enough new knowledge is covered I write a complete game to utilize several of the techniques to illustrate how it all comes together so each new complete project is more complex than the one before. I do cover only Commander X16 specific so I recommend reading Commodore C64 BASIC tutorials and guides.

    Please note that the games and most examples are written with a goal to be as clearly readable and understandable so there is very little source code optimizations.


     Snake Game 

    oOYtAniyluEqKGq-Z6IYr3fc-bdW01qqw_VQP5u2vEZwL5BAUQXWmErnzjQUA0NW-o_IGt__c0SKe5TdkFb3aKSxoq4f4ipjOhM0SlbxoguY2umKOZrNj9nuGBxu6AjmUqtQ4UXG    oPDpxW_K66EjJ-C2B-zzYq7zwd0QonPGrQ44qHIL-tG8WF9mbg1bbJoKohFpHBE86BU122Kr98VU173cwR8lFc26_c-T2KCygEGGhwdU6wy3jdtZZwP3ZWm7xPKn_Bm4weclLt8b    rmmo1izUqdbxJi4uddUn9u9kDt53ndQCKQmmd1HTplwYbOplfZZXtoRPn7dbS8Rh3KLl49G-bW-z_CpXkwrEIbJWVoWmhz6Cy7txanEwyOHNNyHo85r8UShz9scxuSWOv1TwcSal

    This game is written in very clean BASIC with very little trickery so not much special Commander X16 knowledge is required. We do VPOKE directly into video memory so only understanding of fundamentals is required.

    Recommended reading

    GAraTm_TwejiKNrGmFvu_YDAEbUl2eAsCtjMVs1bvjx1gCGz8dmYGIRGltMGJZey0BbpcdEBOAfvrf2lzdDXN1l_1PzmPOwZax5WOZHSfWZu6sJXJNLYqlND9OOiCc8MuXSFytQlVERA Overview

     

    Topics Covered in Game
    Analyzing the game itself is a great way to learn basics like:

    • How to structure source code (outer loops, game loop)
    • What is Game loop
    • Use of Data structure like multiple Arrays
    • How to read Joystick, Keyboard
    • How to use VPOKE to “talk to” VERA
    • Video RAM organization and using colors
    • Writing to certain location on the screen
    • Using PETSCII control characters to display messages and title screen

     

    GOTO Crazy Snake Tutorial

    GOTO Download

     

     

    Tetris Clone

    gILKFp0pW36o62XxJfc8dS7z_-hQ82YVr-MBawFC6cq6JZh-OPMOV-UQad42YaD6v6AQUOxUYXTxvhIsdsQP52R5J4eX_9pad9zjFlygc6LR3qv9gi9jPyngWgAtPNND1L4atY_M    oh6ewn4R1cxTisraVGcGCS-sas2uKU4D-7P8nb2v8kFdOpva623LucBFEpvohrMoCll34E6Il6iIVDZ9tY05eghEPftp42gMZT2mY1UYeZzkqvZ0oqMC7AJRk2P3fnAuaSBcThHc    JPM61wsvucbiBTCxoia-BsN_xZM6liVXAwGAlo3kFiD_N3ZwM8PmcpikKAeYQaBdNd19sC_mKeUVk_wUp4cEM_nRzSM31QON8NGgMy3g1fhIQWFr4MoCAA6P-PEDj_0OxKEcrLMb

    This game introduces some more advanced features of Commander X16 and we have to take a bit more care of how to use data structures and optimize some parts of the game to make it playable.
     

    Recommended reading

    GAraTm_TwejiKNrGmFvu_YDAEbUl2eAsCtjMVs1bvjx1gCGz8dmYGIRGltMGJZey0BbpcdEBOAfvrf2lzdDXN1l_1PzmPOwZax5WOZHSfWZu6sJXJNLYqlND9OOiCc8MuXSFytQlVERA Overview

    GAraTm_TwejiKNrGmFvu_YDAEbUl2eAsCtjMVs1bvjx1gCGz8dmYGIRGltMGJZey0BbpcdEBOAfvrf2lzdDXN1l_1PzmPOwZax5WOZHSfWZu6sJXJNLYqlND9OOiCc8MuXSFytQlTiles in Basic I - Video Modes 0 and 1 

    GAraTm_TwejiKNrGmFvu_YDAEbUl2eAsCtjMVs1bvjx1gCGz8dmYGIRGltMGJZey0BbpcdEBOAfvrf2lzdDXN1l_1PzmPOwZax5WOZHSfWZu6sJXJNLYqlND9OOiCc8MuXSFytQlColors and Palettes

     

    Topics Covered in Game

    Tetris clone requires us to improve on pretty much all parts of the snake game structure:

    • We have additional loops outside and inside game loop
    • Advanced game collisions based on screen state
    • Pre-calculate relative positions of four segments of each tetromino
    • Customize color palette
    • Customize tiles (characters)
    • Speed increase per level
    • Adding sound to the game
       

     

    GOTO Crazy Tetrominoes Tutorial

    GOTO Download

     

     

    Boulder Dash style game

    ud1ty1ycxpxLmtpop5k-PlIOuJRyyH2BE_4VvokAB2s0n4uH61G8wDI2H_eZ0pnl81-bwNyWOjjFIA8MloXGeeWRQ3hMlBh4pRDYrrH8ifftexgKlC2rpXeV_qMJ9RE2ki3q5O4Z    6GQwHXMtGLMWqh0An2Zute9l5PwpGFLnkgQBtxrJ3af8zhRMe9KxXkqGk2AeA_nftq_j2r_YfnHRQ5kWuW_3nKu79kcrARw8wulBFEfbTxIiwCsPZUfBfJ4qsIq5K2ddPV5sBeeZ    FkDDhFMClZ1kMNdJPGkxaHXGdLvjcLCf08RlEBFFUmbHxJs5wemfDspInr4JIp6OPuNHfH8GNfAWEpIxV_l-3oZnwFLaa6xqAWaQ2J93yq__LbfF-HlQ-4fMFW7KJpYTER_5H2mP    

    GOvuu-XJH7UNuQAPFrxNUTkttcAzPnOhTDs4pkE7UpESP4ZhC7P7PK-lfFe_G4ko0mMTZf0YLPjM9TJtw_5SWTj6Vq8RjFS89q5Ei7XzSkx9DWMUzqfKbOBaurK8UxBnT1olfCZo    VoIhp1ZuOsTd-F6FxU-wrDPpbd4dI82dRHZNm764comUrPT4NivAZXdF9w6V6xLps93HX2cPKsqNZZCmwDiHE-ZhpHRXRVjPntjZgKHOASaq7gk0wBZFblZYrPQku3tKnTrO9COy    KagZ6agOfbYQP7Z49lWK8GZ3IzkErgs_K_fRzu9_VJUAdQJzbEcGKWOQO-mK6S-3m3QRFJvunSKxaDyVAnAoqEC6XLiH8cOiudXeDBQ02wF9W0k8EsR2PHU8p9-esOj0hRmK45E-

    3IgVaRRFp5Zfg9c0PHaxWDC4iszptrLPuVmLHO3hhbqG7m6005uhPTka4ck69xJrokufbiJRZLUbv9cQdsqr7Qx5N6OG_7ePZSYCNm5dyARLRYLuHroWAWwkY8X362oII_jrJpdj

     

    With this game we are using most of the Commander X16 hardware capabilities and we are getting close to squeezing most out of it for BASIC games. We have to pay close attention to timings, synchronizing scrolling and animation, take care of different types of collisions, etc.
     

    Recommended reading

     

    GAraTm_TwejiKNrGmFvu_YDAEbUl2eAsCtjMVs1bvjx1gCGz8dmYGIRGltMGJZey0BbpcdEBOAfvrf2lzdDXN1l_1PzmPOwZax5WOZHSfWZu6sJXJNLYqlND9OOiCc8MuXSFytQlVERA Overview

    GAraTm_TwejiKNrGmFvu_YDAEbUl2eAsCtjMVs1bvjx1gCGz8dmYGIRGltMGJZey0BbpcdEBOAfvrf2lzdDXN1l_1PzmPOwZax5WOZHSfWZu6sJXJNLYqlND9OOiCc8MuXSFytQlTiles in Basic I - Video Modes 0 and 1 

    GAraTm_TwejiKNrGmFvu_YDAEbUl2eAsCtjMVs1bvjx1gCGz8dmYGIRGltMGJZey0BbpcdEBOAfvrf2lzdDXN1l_1PzmPOwZax5WOZHSfWZu6sJXJNLYqlND9OOiCc8MuXSFytQlSprites in Basic I - Setup

    GAraTm_TwejiKNrGmFvu_YDAEbUl2eAsCtjMVs1bvjx1gCGz8dmYGIRGltMGJZey0BbpcdEBOAfvrf2lzdDXN1l_1PzmPOwZax5WOZHSfWZu6sJXJNLYqlND9OOiCc8MuXSFytQlSprites in Basic II - Animation

    GAraTm_TwejiKNrGmFvu_YDAEbUl2eAsCtjMVs1bvjx1gCGz8dmYGIRGltMGJZey0BbpcdEBOAfvrf2lzdDXN1l_1PzmPOwZax5WOZHSfWZu6sJXJNLYqlND9OOiCc8MuXSFytQlScrolling and Layers in BASIC

    GAraTm_TwejiKNrGmFvu_YDAEbUl2eAsCtjMVs1bvjx1gCGz8dmYGIRGltMGJZey0BbpcdEBOAfvrf2lzdDXN1l_1PzmPOwZax5WOZHSfWZu6sJXJNLYqlND9OOiCc8MuXSFytQlColors and Palettes

    GAraTm_TwejiKNrGmFvu_YDAEbUl2eAsCtjMVs1bvjx1gCGz8dmYGIRGltMGJZey0BbpcdEBOAfvrf2lzdDXN1l_1PzmPOwZax5WOZHSfWZu6sJXJNLYqlND9OOiCc8MuXSFytQlSimplest Sound Effects Library for BASIC

    GAraTm_TwejiKNrGmFvu_YDAEbUl2eAsCtjMVs1bvjx1gCGz8dmYGIRGltMGJZey0BbpcdEBOAfvrf2lzdDXN1l_1PzmPOwZax5WOZHSfWZu6sJXJNLYqlND9OOiCc8MuXSFytQlFont Library for Commander X16

     

    Topics Covered in Game

    This game is taking advantage of hardware features of Commander X16 to the level it almost looks like 16bit game or something written in Assembly for 8 bit computer like:

    • Two phase approach to development
    • Full color mode
    • Full screen scrolling
    • Two layer graphics
      • Scrollable playfield
      • Static HUD
    • Animated full color sprites
    • 256 color title screen in graphics mode
    • Advanced physics and game mechanics
    • Loading assets to memory from binary files for:
      • Tileset
      • Sprite Sheet
      • Fonts
      • Sound effects library
      • Title screen
         

     

    GOTO Crazy Boulders Tutorial

    GOTO Download

     

    • Like 5
    • Thanks 5

  14. Hmm this is indeed unusual result but also parameters are a bit unusual and it would require some time to debug to understand what exactly is happening.

    To achieve a short percussive envelope I would use setting like this:
    Triangle wave
    AD = $10                          - very short attack, no decay
    SR = $08                          - no sustain, medium long 200ms release
    Not continuous
    Max Volume = 63
    Sustain Volume = 63
    LR = 3                              - my documentation should state that 11 is binary for left and right channel so decimal 3, will update my post
     

    or in code:

    10 LOAD"PLAY.PRG",8,1,$9000
    20 FOR N=0 TO 64+8
    30 READ A
    40 POKE $6000+N,A
    50 NEXT N
    100 REM SETUP CUSTOM INTRUMENTS
    110 SYS $9006
    120 M=PEEK(4)+PEEK(5)*256+6*8
    130 POKE   M,128
    140 POKE M+1,$10
    150 POKE M+2,$08
    160 POKE M+3,0
    165 POKE M+4,63
    170 POKE M+5,63
    190 POKE M+6,3
    800 REM PLAY SONG
    810 POKE 2,$00
    820 POKE 3,$60
    830 SYS $9000
    840 END
    999 REM
    1000 REM ===== HEADER DATA =====
    1001 REM
    1010 DATA 4        :REM NUMBER OF VOICES
    1020 DATA 9        :REM TEMPO
    1030 DATA 64,0     :REM LENGTH (16 BITS)
    1040 DATA 1        :REM AUTOREPEAT ON
    1049 REM
    1050 REM ===== INSTRUMENTS =====
    1051 REM
    1060 DATA 6,0,0,0 : REM CUSTOM INSTRUMENT
    1099 REM
    1100 REM ===== MUSIC DATA =====
    1101 REM
    1110 DATA 40, 0, 0, 0,    0, 0, 0, 0,    0, 0, 0, 0,    0, 0, 0, 0
    1120 DATA  0, 0, 0, 0,    0, 0, 0, 0,    0, 0, 0, 0,    0, 0, 0, 0
    1130 DATA 40, 0, 0, 0,    0, 0, 0, 0,    0, 0, 0, 0,    0, 0, 0, 0
    1140 DATA  0, 0, 0, 0,    0, 0, 0, 0,    0, 0, 0, 0,    0, 0, 0, 0

     

    Please let me know if this creates the effect you were going for? I will try to find some time over the Weekend to investigate strange result your settings created.

     

    • Like 1

  15. 12 hours ago, kliepatsch said:

    Ah silly me 😆

    Here's a short song made for the Music Player Library. Again simply  Ctrl+C  Ctrl+V  it into the emulator. Feel free to modify and use it everyone if you see fit.

    DANDELION.TXT 2.76 kB · 4 downloads

    Wow, this is great tune. Can I include it on my blog (of course with full credits)? Perhaps there will be more that I could add and build a little library of songs for the player.

×
×
  • Create New...

Important Information

Please review our Terms of Use