Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - ben_g

Pages: [1] 2
1
Computer Projects and Ideas / [HTML5/javascript] Platformer game
« on: July 07, 2015, 06:27:22 pm »
As you may have already seen or heard on IRC, I'm working on a platformer game.

At first, this game was meant as an exercise to learn javascript, but I liked it, so I continued working on it.
The point of the game is to get to the green square at the end of the level, while everything that's red is out there to kill you. It's a simple concept, but the game can be quite challenging in some areas.
Here's a screenshot:


You can play it here: http://velocitygames.tk/platformer.html The server we host it on doens't have a very good uptime though, so if it's down, just try again later.

To give you guys a challenge: here are my scores from when I was testing the score displaying code:

These aren't my best scores, but I did get a lot of practice while testing, so they probably aren't that bad either. Feel free to post your scores below.

Currently, there are 4 levels (including the tutorial), but more will be added later.

This topic is also posted on Codewalrus.

2
TI Z80 / [Axe] OXO
« on: March 10, 2015, 06:00:20 pm »
Hi,

I made OXO in axe. For those who don't know the game, it's basically tic-tac-toe, but on a larger board, you need to make 'OXO' instead of a row of the same symbols, and making this combination increases your score instead of giving you an instant win.
It's a lot of fun to play with friends (using single-calc multiplayer), but it also includes an AI which should give you a good challenge.

Screenshot:


controls: you can move the cursor with the arrow keys, [2ND] selects an option in the menu or places an O symbol in game, [ALPHA] places an X in game, [ENTER] confirms the settings in the menu, [S] ([LN]) saves the game and exits (saved games are automatically loaded and deleted at startup) and [CLEAR] ends the game.

Have fun!

EDIT: a 15MHz calc is reccomended (AI calculations are quite slow), but it'll also work at 6MHz.

Click here to download Oxo.

3
Miscellaneous / The Omnimaga Project Revival Team
« on: August 16, 2014, 07:35:15 pm »
Introduction
As most of you will probably know, many projects here tend to die, especially the bigger or more complex ones.
Well, I had an idea that might be able to decrease the number of death projects: We'll team up with some people here on this site (everyone is free to join, regardless of programming skills), and decide on a project to pick up (As long as we have the author's permission to do this). Then, we'll divide the uncompleted part of the project in bite-sized chunks and distribute those chunks to the members of our team that are willing to cooperate in this project. Because everyone will now only have to do a small part of a project, it's far easier to bring it to completion, and it won't take nearly as much time as finishing a complete project, which should decrease the chance of people getting bored with it and putting it asside.

Off course, I nead people to join this team, or else this idea will certainly fail. And I'll be honest: community project don't have a very big chance of success on calculator forums. I just hope that it'll go better with this one because it's lost of small projects instead of one big one.

Guidelines
Please be aware of these guidelines when you join this team:
 - Programming knoledge is advised when you want to joint his team, however, it isn't required. For some projects, we will probably need spriters as well.
 - The author of the project being worked on will act as the team leader (to improve consistency in the project), unless:
          - The author doesn't want to work on his project anymore, or
          - The author will work with us, but doesn't want to be the leader
          In those cases, a democratically chosen volounteer will become the leader.
 - When you decide to join the team, be aware that we may not start by reviving your project first.
 - Anything you create for the team belongs to the whole team. If you decide to quit the team for a certain reason, you shouldn't be able to force the rest of the team to redo your work by suddenly dissalowing them from using your part.
 - Please don't join just to get only your project completed. When you join, do it because you want to revive projects of this community

Proposed project flow (may change in the future)
We won't start with a project right away, because I first want to see if there's enough intrest to actually pull this off. If the team is big enough, we'll start by shoosing a project in the way described below, but to not abuse this, the first project we'll work on will not be one of mine.
1) We'll shose a project amongst the dead projects owned by our team members.
2) If we feel like an other project should be finished before those of our team, we'll try to contact the author asking for the source code and the permission to complete their projects. We'll also try to ask the author as much as we need to know to finish the project in the way he intended it to be.
3) Once the project is selected, we'll check what parts are already fully functional, which parts have to be fixed and which parts are not written yet or have to be entirely rewritten.
4) All those parts get divided into 'modules' based on their function (so they can be put together more easily), and divided amongst the team, based on both what certain people like to do and based on skill (mainly so that speed-sensitive parts can be written by people that write more optimized code).
5) Everyone will be regularly asked to upload the source files and resources they have created to a cloud storage*, so that everyone can see how the whole project is coming along. We may also need a place to discus the code.
6) Hopefully, we manage to complete the project. Then we'll make sure we put the names of our team in the credits, among with the original author and everyone who was in the original credits.
7) Choose the next project (Goto 1)

Conclusion
So, if you are interested in joining this team and performing some CPR on some neat projects that just died too soon, please say so in a reply, and also include your GitHub name. (EDIT: poll added. Please vote in it so we can all easily see how many are willing to participate)
Also if you want to change something about the guidelines or project flow, or just want to add something to this discussion, please do so in a reply.

*For the cloud storage, princetonlion.tibd has created a github that you can access here.

4
TI Z80 / [axe] 3D collision detection library
« on: July 25, 2014, 01:55:59 pm »
So, I've written a library to handle collisions in a 3D world.

I'll explain the features used in the demo based on some screenshots:

Demo room 1


The main feature of tis octogonal room is that it has diagonal walls. It may seem like something ordinary, but diagonal walls are actually quite complicated, and most raycasting engines are unable to render diagonal walls.
This room also has a pillar in the middle that demonstrates a use of the collision hooks: it starts to rise when something (the player) is on top of it, and it descends again when nothing is on top of it.
Nothing here
Demo room 2


This is the most complex room (especially when it comes to rendering) of the demo, so I cheated a bit and used 15MHz for this room. All other rooms do run at 6MHz though.
Anyway, this room is to demonstrate how moving platforms can be used. The horizontally moving platform uses a collision hook to move any objects on it with the platform, while the vertically moving one can work witouth a hook because of gravity.
Ignore this text
Demo room 3



This is just a simple hallway.
Simple white line
Demo room 4



This room uses a floor with a collision hook to create a trampoline. When you hold down the jump key (2ND), you gain a bit of altitude with every jump, when you don't hold 2ND, you lose a bit of altitude with every jump untill you stand still. Jump trough the window to get to the next room.
YAEL (yet another empty line)
Demo room 5



This room uses a ghost object to detect if the player is above the pit, and adjusts the shape of the room to make the player fall.
Last line of transparent text
Demo room 6



This room uses yet another ghost object to detect if the player is in a certain area: When the player is inside the "teleporter", it shows some text, and when the player presses ALPHA, it loads the first room again.
That's all the demo has to offer.

If you are interested in using this library, then check out the file "collision library.txt" in the zip that I'll attach to the post. It contains the documentation about everything the library has to offer.

5
Axe / Looking for a better way to edit axe code
« on: June 02, 2014, 06:44:42 pm »
Hi,


I started getting more active in programming axe lately, but there are a few things bugging me with the options I have to code it.
Currently, I program axe in wabbitemu, with a dumped ROM image. Unfortunately, programming this way is rather hard and slow, since I can't type fast in the emulator, I often have to scroll trough the catalog for some functions, not much of your code is visible, and there is no copy-paste. And on top of that, wabbitemu is rather unstable, which means that I regularly loose some of my work, even though I often take backups. (if you know a way to recover the information lost in such a crash (basically an error message saying "wabbitemu has stopped working"), please share)


I've also looked into some computer editors (tokenizers) for axe, but while they probably work great with basic, they don't seem to work well with axe, since all the ones I found also attempt to tokenize label/variable names with no way to stop that, which generates errors. I know that when you work on your own project, you can try to avoid giving your variables names in which the tokenizer can recougnize tokens, but when you use a library, it can take a long time to rename everything in the library that causes errors after tokenizing, especially if it's still WIP so you have to do that again after every update. And when you are making a library yourself, it's better to give your unctions straightforward and easy to remember names instead of awkward names to avoid them from getting tokenized.


So here comes my question: Does anyone know a better alternative to programming axe? (note that I can't just always program it on my calc) If so, please share.

6
TI Z80 / [axe] GLib model editor (WIP)
« on: November 13, 2013, 04:39:47 pm »
About the poll:
The poll is to decide what would be the best graphical style. These are the screenshots:
'old' b&w graphics'new' grayscale graphics

Original post:

Hi,

As you might know, Themachine created a great axe library to make 3D things in axe.

While he is working on making his lib easyer to use, creating models with it is still rather inconvenient, as it requires you to fill in the raw point data. This is fine for a cube, but for anything more complex, it can help to have a more visual way of doing it.

That is why I started working on a simple model editor. For now, it can only add vertices and move them, but I plan on adding more funtionality as soon as more tutorials are available. The planned functionalities are connecting vertices by lines and polygons and exporting models <format not yet planned>. If you have suggestions for what to add, please post.

There isn't much more I can say about it yet, but I do have a screenshot of it in action:

7
General Calculator Help / usb port problems related to Ti-Lp and Ti-connect
« on: November 03, 2013, 03:33:57 pm »
Hi,

I have already done multiple attempts to get ti-lp to work on this windows 8 laptop, but every time i try to use it, my usb ports just stop working. It never finds the calculator, and it also can't detect other usb devices, like flash drives, regardless of the usb port they were inserted in (Not only the port the calc was in). It stays like this untill the computer is restarted.

After a while, I got tired of this problem and installed Ti-connect, but Ti-Connect seems to have the exact same problem. The usb ports also stop working from the moment Ti-Connect is launched.

This made me think that this problem could be related to windows 8, and I heared from a friend that Ti-Lp works better on Ubuntu, so I used a virtual machine (VM Player) with ubuntu. While the virtual machine was running, I tested it with a flash drive, and it was detected fine in ubuntu(but called "128MB file system" instaed of "MP3 flash drive" like in windows), witouth windows giving me a pop-up about a flash drive being inserted. I think that this means that the virtual machine has full control over the usb ports. Then I downloaded tilp from the ubuntu store, connected a calculator and ran it. And again, it didn't find a calculator, and just like in windows, all usb ports stopped working, and not only in ubunto, when I swhitched back to windows, the problem remained.
This made me think that the problem might be hardware-related.

Does anyone know the cause of this idea, a fix for it, or something else that I can try to get it to work?

8
Art / Sprite request for Back to Cretaceous [computer]
« on: July 23, 2013, 05:44:55 pm »
Hi,

As you may or may not know, I'm working on a java online RPG. I am currently working very hard on it to get it ready for beta (I have a deadline, but I'm not sure if I'll make it, so I'm not going to tell it yet). The graphics of the 3D models are all reasonable for a beta version, but I have always been using very simple graphics (=coloured circles) for the item sprites. I have done a few attempts at drawing item sprites, but they looked awfull.

If anyone wants to give it a try, I'll write the specifications:
 - Theme: The graphics of the game itself are meant to look reasonably realistic, but the theme of the menus (and thus the inventory) is more simple (it contains large areas of rougly the same colour), so I think that for the item sprites, a simple or cartoonish theme would look best, but an other theme will probably look good as well as long as all items have the same theme (Note that items that appear in the 3D space (like wieldable items) wil have a seperate model, so the item sprite is only displayed in the inventory.
 - Size: Preferably 32*32. If you can't do 32*32, please use at least 20*20. The image has to be square. Make sure that the item is still recougnizable at a 20*20 resolution.
 - Background: The background must be transparent.
 - format: png

Some items you can try:
 - An iron axe
 - A box (just a plain, cardboard box)
 - A stick (branch of a tree)
 - A pile of leaves
 - A log

If you still have questions, feel free to ask them. And of course, if you make sprites, I'll put your name in the credits.

9
Java / function not getting called
« on: February 19, 2013, 04:26:19 pm »
I have a strange problem in my current code: When I call Controls.requestKeyChange from MenuController.changeControls, it just seems to return from changeControls.

My code:

MenuController.java:
Code: [Select]
public class MenuController extends AbstractAppState implements ScreenController{
    //...
    public void changeControls(String s){
        ControlsButton1.setText("Press any button...");
        System.out.println("changeControls in MenuController called (Action: "+Controls.Action.values()[Integer.parseInt(s)]+" )");
        Controls.requestKeyChange(Controls.Action.values()[Integer.parseInt(s)], app.getInputManager(), new Runnable() {
            public void run() {
                ControlsButton1.setText(Controls.keyName);
            }
        });
    }
}

Controls.java:
Code: [Select]
public class Controls implements ActionListener{
 
    //...
    public static void requestKeyChange(Action action,InputManager im, Runnable executeWhenDone){
       
        System.out.println("requestKeyChange called (Arguments: "+action+", "+im+", "+executeWhenDone);
       
        r = executeWhenDone;
        removeControls(im);
        setupKeyNames();
       
        for(int i=0; i<keyCodes.size(); i++){
            im.addMapping(keyNames.get(i), keyboard.get(i) ? new KeyTrigger(keyCodes.get(i)) : new MouseButtonTrigger(keyCodes.get(i)));
        }
       
        System.out.println(im.toString());
       
        changingControls = true;
    }
}

Console output:
Code: [Select]
//...
changeControls in MenuController called (Action: moveUp )
BUILD SUCCESSFUL (total time: 20 seconds)

Does anyone know why this happens?

10
TI Z80 / Racing game (revived)
« on: June 15, 2012, 07:16:44 pm »
WARNING: THIS POST IS OUTDATED!

This is the project I've been working on since the start of the contest. I haven't done much yet because I'm busy with exams lately.

It is going to be a racing game in which you race against AI, and there will be some items you can use to go faster or to slow down other players (similar to mario kart).
It uses the 3D engine of my other game (Alien invasion), but this one is improved and supports textures, solid triangles and wireframe, instead of only textures.
This is what I have so far:

This is the track, which already works graphics-wise, but it hasn't got any collision checking yet. The track is fully wireframe (and will probably stay like that). The track is fully 3 dimensional, which means it can go left, right, up and down, but models for up and down haven't been created yet. The cube in the center of the screen is the placeholder for the car. The car will probably be mostly wireframe, to fit in the simulation-like theme of the track (of which the current name, 'cyber racer', comes).

Right now the graphics are quite bad, but I might add some models to the sides of the track as illustrations, if the speed will allow it when AI and items are added). Right now, it runs in 15MHz mode, and has 18 fps. But it still looks smooth.

I guess that's all I can say about it now.
For this project I can't include the source because of the rules of the contest. If you want to use the 3D engine in your own project, I can give you the engine of my previous project.

11
ASM / optimizing asm code
« on: April 17, 2012, 04:27:08 pm »
Hi,

I have to optimize this code, But I haven't really optimized before and whatever I try to do, I can't get it to work faster. Can anyone give me some tips?

Also: I'm optimizing for speed, not for size. The code can be quite big.

Here's the code itself:
Spoiler For code:
Code: [Select]
DrawTriangle:
  ;IN: x1,y1,u1,v1,x2,y2,u2,v2,x3,y3,u3,v3
  ;scherm = 96*64

;the following code was used to add 100 to the x coordinates, to see if the sign was the problem

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;  ld de, 100
;  ld hl, (x1)
;  add hl, de
;  ld (x1), hl
;  ld hl, (x2)
;  add hl, de
;  ld (x2), hl
;  ld hl, (x3)
;  add hl, de
;  ld (x3), hl
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;---------------------------------------------------------------
; This part sorts the points so that Y1 <= Y2 <= Y3 so
; we can just draw each scanline below the last one.
;---------------------------------------------------------------

  ld hl, (x1)
  call Signed16To8
  ld h, $FF
  ld l, a
  ld (x1), hl
  ld hl, (x2)
  call Signed16To8
  ld h, $FF
  ld l, a
  ld (x2), hl
  ld hl, (x3)
  call Signed16To8
  ld h, $FF
  ld l, a
  ld (x3), hl

  ld hl, (y1)
  ld de, (y2)
  cpHLDE
  jr c, Y1SmallerThanY2

  ld hl, x1
  ld de, dx1 ;temp location
  ld bc, 6 ;size
  ldir

  ld hl, x2
  ld de, x1
  ld bc, 6
  ldir

  ld hl, dx1
  ld de, x2
  ld bc, 6
  ldir

Y1SmallerThanY2:
  ld hl, (y1)
  ld de, (y3)
  cpHLDE
  jr c, Y1SmallerThanY3

  ld hl, x1
  ld de, dx1 ;temp location
  ld bc, 6 ;size
  ldir

  ld hl, x3
  ld de, x1
  ld bc, 6
  ldir

  ld hl, dx1
  ld de, x3
  ld bc, 6
  ldir

Y1SmallerThanY3:
  ld hl, (y2)
  ld de, (y3)
  cpHLDE
  jr c, Y2SmallerThanY3

  ld hl, x2
  ld de, dx1 ;temp location
  ld bc, 6 ;size
  ldir

  ld hl, x3
  ld de, x2
  ld bc, 6
  ldir

  ld hl, dx1
  ld de, x3
  ld bc, 6
  ldir

Y2SmallerThanY3:

; +++++ End of sorting code +++++


;----------------------------------------------------------
; Here, some variables are initialized. The delta
; variables (the variables which start with a 'd')
; contain the values that need to be added to
; the variables which start with a 't'. Variables
; with a 't' and a '1' are used for the start of
; the scanline. Those with a 't' and a '2' are used
; for the end of the scanline.
;----------------------------------------------------------

  res 0, (IY) ;if this bit is 0, the routine is drawing the top half of the triangle. if it's 1, it's drawing the bottom half.
  res 1, (IY) ;This bit is used to store if the deltas for the texture coordinates inside scanlines are already calculated. They are constants, so they only need to be calculated once per half.

  ld hl, (y2)
  ld de, (y1)
  subFP ;This routine is for substracting fixed-point values, but here it's used to substract integer values.
  ld h, l
  ld l, 0
  push hl
  ld hl, (x2)
  ld de, (x1)
  subFP
  ld h, l
  ld l, 0
  pop de
  call DivFP
  ld (dx1), hl
  ld hl, (y3)
  ld de, (y2)
  subFP
  ld h, l
  ld l, 0
  push hl
  ld hl, (x3)
  ld de, (x2)
  subFP
  ld h, l
  ld l, 0
  pop de
  call DivFP
  ld (dx2), hl
  ld hl, (y3)
  ld de, (y1)
  subFP
  ld h, l
  ld l, 0
  push hl
  ld hl, (x3)
  ld de, (x1)
  subFP
  ld h, l
  ld l, 0
  pop de
  call DivFP
  ld (dx3), hl


  ld hl, (y2)
  ld de, (y1)
  subFP
  ld h, l
  ld l, 0
  push hl
  ld a, (u2)
  ld h, a
  ld l, 0
  ld a, (u1)
  ld d, a
  ld e, 0
  subFP
  ;ld h, l
  ;ld l, 0
  pop de
  call DivFP
  ld (du1), hl
  ld hl, (y3)
  ld de, (y2)
  subFP
  ld h, l
  ld l, 0
  push hl
  ld a, (u3)
  ld h, a
  ld l, 0
  ld a, (u2)
  ld d, a
  ld e, 0
  subFP
  ;ld h, l
  ;ld l, 0
  pop de
  call DivFP
  ld (du2), hl
  ld hl, (y3)
  ld de, (y1)
  subFP
  ld h, l
  ld l, 0
  push hl
  ld a, (u3)
  ld h, a
  ld l, 0
  ld a, (u1)
  ld d, a
  ld e, 0
  subFP
  ;ld h, l
  ;ld l, 0
  pop de
  call DivFP
  ld (du3), hl


  ld hl, (y2)
  ld de, (y1)
  subFP
  ld h, l
  ld l, 0
  push hl
  ld a, (v2)
  ld h, a
  ld l, 0
  ld a, (v1)
  ld d, a
  ld l, 0
  subFP
  ;ld h, l
  ;ld l, 0
  pop de
  call DivFP
  ld (dv1), hl
  ld hl, (y3)
  ld de, (y2)
  subFP
  ld h, l
  ld l, 0
  push hl
  ld a, (v3)
  ld h, a
  ld l, 0
  ld a, (v2)
  ld d, a
  ld e, 0
  subFP
  ;ld h, l
  ;ld l, 0
  pop de
  call DivFP
  ld (dv2), hl
  ld hl, (y3)
  ld de, (y1)
  subFP
  ld h, l
  ld l, 0
  push hl
  ld a, (v3)
  ld h, a
  ld l, 0
  ld a, (v1)
  ld d, a
  ld e, 0
  subFP
  ;ld h, l
  ;ld l, 0
  pop de
  call DivFP
  ld (dv3), hl

  ld hl, (x1)
  bit 7, h
  jr z, TPos1
  ld (tx1+1),hl \ ld a, $FF \ ld (tx1),a
  ld (tx2+1),hl \ ld a, $FF \ ld (tx2),a
  jr TEnd1
TPos1:
  ld (tx1+1),hl \ xor a \ ld (tx1),a ;store the 16bit integer at hl into 16.8 fixed point number tx1
  ld (tx2+1),hl \ xor a \ ld (tx2),a
TEnd1:
  ld hl, (y1)
  ld (_ty), hl

  ld a, (u1)
  ld h, a
  ld l, 0
  ld (tu1), hl
  ld (tu2), hl
  ld a, (v1)
  ld h, a
  ld l, 0
  ld (tv1), hl
  ld (tv2), hl

;if Y1 == Y2, then we don't need to draw the first half.
  ld hl, (Y1)
  ld de, (y2)
  cpHLDE
  jp z, __TEndLoop

; +++++ End of initializing code +++++


;------------------------------------------------------------
; This is the loop in which the triangle is drawn.
; In each interval of the loop, a single scanline is
; drawn. When this loop finished, one half of the
; triangle is drawn.
;------------------------------------------------------------

TDrawLoop:
  ld a, (_ty)
  ld d, a
;if the Y of the scanline is negative, then go to the next one.
  bit 7, a
  jp nz, Clip
  ld a, (_ty)
;If it reaches the bottom of the screen, then stop drawing the triangle.
  cp 64
  ret nc

;Initialize variables for the scanline
  ld hl, (tu1)
  ld (tmpu), hl
  ld hl, (tv1)
  ld (tmpv), hl
  ld hl, (tu2)
  ld (temp2), hl
  ld hl, (tv2)
  ld (temp3), hl
  ld a, (tx2+1)
  ld (temp+1), a
  add a, 128
  ld b, a
  ld a, (tx1+1)
  ld (temp), a
  add a, 128
  cp b
  jr c, TOrdered
  ;jp po, TOrdered
  ld hl, (tu2)
  ld (tmpu), hl
  ld hl, (tv2)
  ld (tmpv), hl
  ld hl, (tu1)
  ld (temp2), hl
  ld hl, (tv1)
  ld (temp3), hl
  ld a, (tx2+1)
  ld (temp), a
  ld a, (tx1+1)
  ld (temp+1), a
TOrdered:
  ld l, d
  ld a, (temp)
;folowing line was for the test to see if the sign was the problem
  ;sub 100 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  bit 7, a
  jr z, TGetPixel
  xor a
TGetPixel:
  call GetPixel
  ld (mask), a
  ld (pointer), hl

;If the deltas for the texture coordinates inside a scanline are already
;calculated, then calculating them again is a wast of cycles.
  bit 1, (IY)
  jr nz, TPlotLoop
  ld hl, (tx1)
  ld de, (tx2)
  cpHLDE
  jr z, TPlotLoop
  ld a, (temp)
  ld h, a
  ld l, 0
  ld a, (temp+1)
  ld d, a
  ld e, 0
  subFP
  push hl
  ld hl, (tmpu)
  ld de, (temp2)
  subFP
  pop de
  call DivFP
  ld (tmpdu), hl
  ld a, (temp)
  ld h, a
  ld l, 0
  ld a, (temp+1)
  ld d, a
  ld e, 0
  subFP
  push hl
  ld hl, (tmpv)
  ld de, (temp3)
  subFP
  pop de
  call DivFP
  ld (tmpdv), hl
  set 1, (IY)


;---------------------------------------------------------------------
; In this loop, the scanline is drawn. One interval here
; draws one pixel. When the loop ends, one scanline is drawn.
;---------------------------------------------------------------------

TPlotLoop:
;If the x coordinate of the pixel is negative, then go to the next pixel.
  ld a, (temp)
  bit 7, a
  jr nz, TNoCarry

;if the pixel goes of the right side of the screen, then go to the next scanline
  cp 96
  jp nc, Clip

;Everything with 4 ;'s behind it are for 16x16 textures. Remove those and the
;textures will be 8x8.

  ld a, (tmpv+1)
  add a, a ;;;;
  ld hl, texture
  add a, l
  ld l, a

  ld a, (tmpu+1)
  bit 3, a ;;;;
  jr z, TFirstByte ;;;;
  res 3, a ;;;;
  inc hl ;;;;
TFirstByte: ;;;;
  ld b, a
  inc b
  ld a, (hl)
TshiftLoop:
  rla
  djnz   TshiftLoop
 
  ld a, (mask)
  ld hl, (pointer)
  jr c, TSetPixel

TResPixel:
  ;ld a, b
  cpl
  and (hl)
  ld (hl), a
  jr TEndPlot

TSetPixel:
  ;ld a, b
  or (hl)
  ld (hl), a

TEndPlot:
  ld hl, mask
  rrc (hl)
  jr nc, TNoCarry
  ld hl, (pointer)
  inc hl
  ld (pointer), hl
TNoCarry:

  ld hl, (tmpu)
  ld de, (tmpdu)
  add hl, de
  ld (tmpu), hl
  ld hl, (tmpv)
  ld de, (tmpdv)
  add hl, de
  ld (tmpv), hl

  ld a, (temp+1)
  ld b, a
  ld a, (temp)
  ld hl, temp
  inc (hl)
  cp b
  jp nz, TPlotLoop

; +++++ End of pixel plotting code +++++

;If it's drawing the secound half, then make it recalculate the thexture deltas
;for inside the scanlines. This was to solve a bug in the texture mapping.
  bit 0, (IY)
  jr nz, aaaa ;I suddenly ran out of inspiration for label names
;  res 1, (IY)
aaaa:

Clip:
  ld hl,(tx1)
  ld de, (dx1)
  ld a, d
  rla
  sbc a, a
  ld b, a
  add hl, de
  ld (tx1), hl
  ld a, (tx1+2)
  adc a, b
  ld (tx1+2), a

  ld hl,(tx2)
  ld de, (dx3)
  ld a, d
  rla
  sbc a, a
  ld b, a
  add hl, de
  ld (tx2), hl
  ld a, (tx2+2)
  adc a, b
  ld (tx2+2), a

  ld hl, (tu1)
  ld de, (du1)
  add hl, de
  ld (tu1), hl
  ld hl, (tu2)
  ld de, (du3)
  add hl, de
  ld (tu2), hl

  ld hl, (tv1)
  ld de, (dv1)
  add hl, de
  ld (tv1), hl
  ld hl, (tv2)
  ld de, (dv3)
  add hl, de
  ld (tv2), hl


  ld hl, (_ty)
  inc hl
  ld (_ty), hl
  ld de, (y2)
  cpHLDE
  jp c, TDrawLoop

;This is the end of the drawing loop
;If the secound half was drawn, then stop this routine.
  bit 0, (IY)
  jr nz, _TEnd

__TEndLoop:
  ;Here, some variables are initialized for drawing the secound half.

  ld hl, (y2)
  ld (_ty), hl

  ld hl, (y3)
  ld (y2), hl
  ld hl, (dx2)
  ld (dx1), hl
  ld hl, (du2)
  ld (du1), hl
  ld hl, (dv2)
  ld (dv1), hl

  ld hl, (x2)
  bit 7, h
  jr nz, TPos4
  ld (tx1+1),hl \ ld a, $FF \ ld (tx1),a
  jr TEnd4
TPos4:
  ld (tx1+1),hl \ xor a \ ld (tx1),a
Tend4:

  ld a, (u2)
  ld h, a
  ld l, 0
  ld (tu1), hl
  ld a, (v2)
  ld h, a
  ld l, 0
  ld (tv1), hl

  set 0, (IY)

  jp TDrawLoop

_TEnd:

  ret



getPixel:
   bit 7, a
   ret nz
   bit 7, l
   ret nz
   ld   h, 0
   ld   d, h
   ld   e, l
   
   add   hl, hl
   add   hl, de
   add   hl, hl
   add   hl, hl
   
   ld   e, a
   srl   e
   srl   e
   srl   e
   add   hl, de
   
   ld   de, PlotSScreen
   add   hl, de
   
   and   7
   ld   b, a
   ld   a, $80
   ret   z
   
   rrca
   djnz   $-1
   ret

note: I'm not asking to optimize it for me, but to help me optimize it, so I can learn from this and optimize better in the future.

12
Other / calculator(84+) - arduino communication trough USB
« on: April 08, 2012, 04:35:10 pm »
I wrote some communication routines to send bytes from an 84+ calculator to the arduino (not from arduino to calc).
Here is the example code:

z80:
Code: [Select]
.org $9D93
#define bcall(label) rst 28h \ .dw label

#include "ti83plus.inc"

.db t2ByteTok, tAsmCmp

  call USB_Init

  bcall(_GetKey)

  ;send 50
  ld b, 50
  call USB_SendByte

  ret

;------------------------------------------------
; calc-Arduino communication routines trough USB
;------------------------------------------------


USB_Init:
  ;initializes the USB connection

  ;turn the USB driver off so we can read and write manually
  bcall(810Eh) ;KillUSB

  ;put the D- line on low
  ld a, %00100000
  out ($4A), a

  ret


USB_SendByte:
  ;b = the byte to be send
  ld c, 0
  ;c = bitcounter

  call Wait

  ;set D- to high so the arduino knows we will send a byte
  ld a, %00011000
  out ($4A), a

  ;wait untill we can start sending the byte
  call Wait

SendLoop:
  ;put the bit we are going to send in carry
  rrc b

  jr c, sendOne

  ;send a 0
  ld a, %00100000
  out ($4A), a
  jr endBit

sendOne:
  ;send a 1
  ld a, %00011000
  out ($4A), a

endBit:
  ;increase the bit counter
  inc c

  ;stop sending if all 8 bits were sent
  ld a, c
  cp 8
  jr z, endSend

  call Wait
  jr sendLoop

endSend:
  ;set D- low so the arduino won't think we're trying to send an other byte
  ld a, %00100000
  out ($4A), a

  ret


;internally used routine(s)
;--------------------------

wait:
  ;waits untill you can send a bit

  ;if the clock is 0: wait untill it's 1
  in a, ($4D)
  bit 1, a
  jr z, Wait

waitLoop2:
  ;Wait untill the clock is 0, so we can begin writing
  in a, ($4D)
  bit 1, a
  jr nz, WaitLoop2

  ret

arduino
Code: [Select]

//Dp and Dm are the data kables of the USB
const int Dp = 5;
const int Dm = 6;
const int Delay = 1;

int RecievedByte = 0;
int Recieving = 0;
int RecievedBit = 0;
int Recieved = 0;
int ledOn = 0;

void setup(){
  pinMode(Dp, OUTPUT);
  pinMode(Dm, INPUT);
  pinMode(13, OUTPUT);
}


void loop(){
  digitalWrite(Dp, HIGH);
  //clock = 1 so we'll read a bit
  if(Recieving == 0){
    //if nothing is being sent, we have to check for a 1
    if(digitalRead(Dm) == HIGH){
      //1 was send, so we'll have to recieve a byte
      Recieving = 1;
      RecievedBit = 0;
      RecievedByte = 0;
    }
  } else {
    //save the received bit
    if(digitalRead(Dm) == HIGH){
      bitSet(RecievedByte, RecievedBit);
    } else{
      bitClear(RecievedByte, RecievedBit);
    }
    RecievedBit++;
    if(RecievedBit == 8){
      //if all 8 bits are sent, the byte is complete.
      Recieving = 0;
      Recieved = 1;
    }
  }
  delay(Delay);
  digitalWrite(Dp, LOW);
  if(Recieved){
    if(RecievedByte == 50){
      if(ledOn == 0){
        digitalWrite(13, HIGH);
        ledOn = 1;
      } else {
        digitalWrite(13, LOW);
        ledOn = 0;
      }
      RecievedByte = 0;
    }
    Recieved = 0;
  }
  delay(Delay);
}

HOW TO USE THE EXAMPLE PROGRAMS:
- BACKUP YOUR PROGRAMS AND OTHER IMPORTANT DATA ON YOUR CALC
- compile the z80 program (I used SPASM) and send it to your calc.
- send the programs to the arduino and the calc.
- if the arduino hasn't got an on-board LED, connect one (and a resistor!) to pin 13.
- cut a USB mini male end of a USB cable (make sure the wire attached to it is long enough, works with both A-type and B-type (both have been tested)).
- connect the white wire of the USB to pin 6, the green wire to pin 5 and the black wire to the GND.
- make sure the arduino is powered and insert the USB cable into the calc's USB port.
- run the assembly program with Asm( on the calc

When you run the program, press a key. The led should now turn on. When you run it and press a key again, the led should turn off. If your calc freezes, make sure the arduino is powered, the black wire is connected to the GND, runs the correct software and is connected to your calc.

What this does is: when you press a key on the calc, it sends a byte with a value of 50 to the arduino. The arduino notices a byte is send and checks if it's 50. If it's 50, pin 13 will toggle.

It may be very unoptimized (especially the arduino part, I learned the language two days ago), but it works. I hope this code can be usefull to anyone.

Also: thank you, Thepenguin77. Without your help, I wouldn't be able to control the USB port.

13
TI Z80 / [axe] 2D minecraft game
« on: March 23, 2012, 07:02:59 pm »
IMPORTANT: This project hasn't been worked on for a while, and I'm sorry to say it, but it's very lickely that this game, in it's current form, will never be worked on again.
If you want to see the source code, check this post.


original post:

During a few days of being bored while no computer was available, I started to make a game similar to minecraft in axe. Right now, you can only play in creative mode and save only one 24*25 world (can be easily changed in the scource code). It has got 9 blocks so far (the engine supports 15(air not included)), and sand will fall when there is no block underneath it (but only when it's visible). The world isn't generated yet, so you just start with an empty square of 22*23 blocks (edges are made of bedrock, which can't be broken to avoid corrupting memory).

Here's a screenshot showing it in action:
Spoiler For screenshot in spoiler because it causes a bit of lag:

If you want to play minecraft during class: here's a (DCS) executable:
http://dl.dropbox.com/u/11215358/MCWORLD2.8Xp

If you need an other shel or you want to see or modify the source:
http://dl.dropbox.com/u/11215358/MINESRC2.8Xp

Controls:
arrow keys: move
5: build mode (indicated by a black block at the right bottom of the screen)
2: break mode (indicated by the grey block at the right bottom of the screen)
+: next block (the current block is shown in the bottom right part of the screen)
-: previous block
1, ., 3, 4, 6, 8: place or break a block. 5 and 2 represent the character. The keys around it represent the places around the character. Press one of those keys to place or break a block in that place (depends of if you are in build mode or in break mode)
CLEAR: quit game. This will automatically save the world, but you will always start in the upper left corner of the world.

Bugs? Feature suggestions? comments? complaints? If you have them, please post them.

14
Computer Usage and Setup Help / Connect laptop to wifi
« on: March 16, 2012, 07:24:04 pm »
I have an old laptop here, and it always connected to the internet using wifi well, but a few days ago, it suddenly stopped connecting. When I use thinkvantage acces connections, it can detect the network, but when it tries to configure an ip, it says 'connection failed'. Is there a way to fix this?

15
TI Z80 / polygon-based 3D engine (with textures)
« on: December 11, 2011, 03:23:20 pm »
I have been working on a polygon-based 3D engine for a while, and the 3D itself works, and the textures work too, there are still some bugs, but I already know what is causing them.

This is how it looks like:


I decided to keep it open-scource. I'll try to update the source often.
The source code is included in the post. A compiled version is also included. If you use any code in your own project, you don't have to give me credits, and you can always ask for help for using it on this topic.

Source is not fully commented, but I'll try to do that in a few days.

Credits:

This is everybody who helped me:
Hot_Dog
jacobly
thepenguin77
timoty
Runer112
leafiness0
Builderboy
Qwerty.55
t0xic_kitt3n
ztrumpet
calc84maniac
shmibs
p2
chattahippie
christop (cemetech)
KermMartian (cemetech)
benryves (cemetect)
Dr. Best (Ultimate 3D)

If you helped me but I forgot to ad you, please tell. If I put you in this list but you don't want to be in the credits,please tell too.

Pages: [1] 2