Skip to content

Commit

Permalink
Merge pull request #68 from PainsPerdus/testing
Browse files Browse the repository at this point in the history
First milestone!
  • Loading branch information
DorianXGH committed Jun 27, 2020
2 parents 5744f60 + 5436fd2 commit c5cdb11
Show file tree
Hide file tree
Showing 52 changed files with 2,887 additions and 526 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
@@ -0,0 +1,3 @@
[submodule "GBDefs"]
path = GBDefs
url = https://github.com/PainsPerdus/GBDefs
1 change: 1 addition & 0 deletions GBDefs
Submodule GBDefs added at 202755
20 changes: 12 additions & 8 deletions Makefile
Expand Up @@ -8,6 +8,10 @@ LINKER=wlalink
AFLAGS=
LFLAGS=-d -v -s

#Emulator
EMULATOR=sameboy
EFLAGS=

# Folders
SRC=src
BIN=bin
Expand All @@ -16,8 +20,8 @@ INSTALL="/media/B009-9376/1 Game Boy/5 Team Rocket"

# Files
TARGET=rocket
SOURCE_FILES =\
pong.s
SOURCE_FILES = \
main.s

##############
# Directives #
Expand All @@ -26,10 +30,10 @@ OBJECT_FILES = $(SOURCE_FILES:%.s=$(BIN)/%.o)
TARGET_FILE = $(BIN)/$(TARGET).gb
LINK_FILE = $(BIN)/linkfile

all: directories $(TARGET_FILE)
all: clean directories $(TARGET_FILE)

run: all
vbam -f 17 $(TARGET_FILE)
$(EMULATOR) $(EFLAGS)$(TARGET_FILE)

install: all
cp $(TARGET_FILE) $(INSTALL)
Expand All @@ -43,13 +47,13 @@ directories:

.PHONY: build clean directories

$(TARGET_FILE): $(OBJECT_FILES) $(LINK_FILE)
$(TARGET_FILE): $(OBJECT_FILES) $(LINK_FILE)
echo "Building $(OBJECT_FILES)"
$(LINKER) $(LFLAGS) -r $(LINK_FILE) $(TARGET_FILE)

$(BIN)/%.o: $(SRC)/%.s
$(ASSEMBLER) $(AFLAGS) -I $(INCLUDE) -o $@ $<
$(ASSEMBLER) $(AFLAGS) -I $(INCLUDE) -o $@ $<

$(LINK_FILE):
$(LINK_FILE):
echo "[objects]" > $(LINK_FILE)
printf "%s\n" $(OBJECT_FILES) >> $(LINK_FILE)
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -2,7 +2,7 @@

## Description

This project aims to remake the popular game *The Binding of Isaac* for Gameboy classic, in assembly.
This project aims at remaking the popular game *The Binding of Isaac* for Gameboy classic, in assembly.

## Features

Expand Down
53 changes: 53 additions & 0 deletions doc/CollisionSolverEntities.doc.md
@@ -0,0 +1,53 @@
# Collision Solver for Entities other than Isaac

## Label

`collisionSolverEntities`

## Parameters

| Label | Type | Size/Struct | Description |
| ----- | ---- | ----------- | ----------- |
| b | register | 1 byte | the 2 left bits tell whether the collision happens during (respectively) horizontal or vertical movement |
| hl | register | 2 bytes | address to the caracter's sheet of the element |
| collisionSolver_.collidingEntity | fixed address | element pointer | address to the element representing the entity |

## Struct

Description of the collisionSolver_var struct in the CollisionSolverEntities.var.s file

| Label | Size/Struct | Description |
| ----- | ----------- | ----------- |
| collidingEntity | element pointer | address to the element representing the entity |

## Return

None

## Pseudo Code

~~~C
// a function for when an entity collides with any element
char void solve_collision_to_Isaac (
char touched_from, // b register
element.sheet* s, // hl register
element entity) { // collisionSolver_.collidingEntitty

if (0b00010000 and s.size) // is the element blocking
if (touched_from and 0b10000000) //Entity touches during horizontal movement
Entity.x = Entity.x - ((Entity.speed and 0b11110000)/16)
if (touched_from and 0b01000000) //Entity touches during vertical movement
Entity.y = Entity.y - (Entity.speed and 0b00001111)

}
~~~
## Note
Same function as for Isaac, but with less cases here (other entities donc take contact damages, and can't activate anything.
For now, the informations given in the b register is not used in the actual implementation, as the collision function isn't able to detect direction of the impact. The code simply reverse the movement.
## TODO
* the rollback technique to manage collision with blocking elements is likely not to be the best, as it can cause lines of uncrossable pixels between Isaac and the element.
51 changes: 51 additions & 0 deletions doc/CollisionSolverIsaac.doc.md
@@ -0,0 +1,51 @@
# Collision Solver for Isaac

## Label

`collisionSolverIsaac`

## Parameters

| Label | Type | Size/Struct | Description |
| ----- | ---- | ----------- | ----------- |
| b | register | 1 byte | the 2 left bits tell whether the collision happens during (respectively) horizontal or vertical movement |
| hl | register | 2 bytes | address to the caracter's sheet of the element |

## Return

None

## Pseudo Code

~~~C
// a function for when Isaac collides with any element
char void solve_collision_to_Isaac (
char touched_from, // b register
element.sheet* s) { // hl register

if (0b10000000 and s.size) // is the element blocking
if (touched_from and 0b10000000) //Isaac touches during horizontal movement
Isaac.x = Isaac.x - ((Isaac.speed and 0b11110000)/16)
if (touched_from and 0b01000000) //Isaac touches during vertical movement
Isaac.y = Isaac.y - (Isaac.speed and 0b00001111)

/* if (0b01000000 and s.size) // does the element hurt Isaac
if (Isaac.recover == 0)
Isaac.hp = Isaac.hp - s.dmg;
Isaac.recover = RECOVERYTIME;

if (0b00100000 and s.size) // does the element react to Isaac's touch
s.function();
*/
}
~~~
## Note
We mustn't forget to decrease the recover counter at each VBLank call.
For now, the informations given in the b register is not used in the actual implementation, as the collision function isn't able to detect direction of the impact. The code simply reverse the movement.
## TODO
* the rollback technique to manage collision with blocking elements is likely not to be the best, as it can cause lines of uncrossable pixels between Isaac and the element.
122 changes: 122 additions & 0 deletions doc/check_inputs.doc.md
@@ -0,0 +1,122 @@
# Input checker

## Main include

This code updates the values of Isaac regarding the states of the buttons.

### file to include:

`check_inputs.s`

### Parameters:

### Return:


### Modified values:

| Label | Type | Size/Struc |
| ------------- | ------------- | ---------- |
| a | register | 1 byte |
| b | register | 1 byte |
| c | register | 1 byte |
| hl | register | 2 bytes |
| global_.isaac.speed | fixed address | 1 byte |
| global_.isaac.direction | fixed address | 1 byte
| global_.isaac.tears | fixed address | 1 byte |

### Global variables used

| Label | Size | Description |
| ------------- | ---------- | ----------- |
| global_.isaac.speed | 1 byte | Isaac speed (split in 2 x 4bits, x speed and y speed. [7:4]: x speed, [3:0]: y speed) |
| global_.isaac.direction | 1 byte | 2 bits indicate Isaac's direction (11 = up, 00 = down, 01 = right, 10 = left) (pos 1:0), 6 other bits are free |
| global_.isaac.tears | 1 byte | 3 bits for horizontal speed of tears (pos 5:3), 3 bits for vertical speed (pos 2:0), 1 flag for "A was pressed the frame before" in postion (pos 7), 1 flag for "B was pressed" (pos 6)|

### Global structs used


#### Isaac

Content of the struct "isaac" :

| Label | Size/Struct | Description |
| ----- | ---- | ----------- |
| x | 1 byte | abscissa of Isaac |
| y | 1 byte | ordinate of Isaac |
| hp | 1 byte | health point of Isaac |
| dmg | 1 byte | damage dealt by Isaac |
| upgrades | 2 bytes | upgrades earned by Isaac (flags, to be defined) |
| range | 1 byte | 7 bits for range of Isaac's tears (pos 6:0), 1 flag that tells if a tear was shot during the previous image (pos 7)|
| speed | 1 byte | Isaac speed (split in 2 x 4bits, x speed (pos 7:4) and y speed (pos 3:0)) |
| tears | 1 byte | 3 bits for horizontal speed of tears (pos 5:3), 3 bits for vertical speed (pos 2:0), 1 flag for "A was pressed the frame before" in postion (pos 7), 1 flag for "B was pressed" (pos 6)|
| recover | 1 byte | recovery time |
| bombs | 1 byte | number of bombs Isaac has |
| direction | 1 byte | 2 bits indicate Isaac's direction (11 = up, 00 = down, 01 = right, 10 = left) (pos 1:0), 6 other bits are free |


### Reserved memory:


### Pseudo code

~~~C
// INIT ARROW
(0xFFEE) = %00100000; // select the arrow keys
b = get_arrow_values();
// CHECK ARROWS
// speed_x = a[7:4], speed_y = a [3:0]
// global_.isaac.direction = c[1:0]
speed_x = 0;
speed_y = 0;
// direction = %11; --//By default, isaac looks at YOU!--
// Isaac no retains its position
if (down_arrow(b)){
speed_y = 1;
direction = %11;
}else if (up_arrow(b)){
speed_x = -1;
direction = %00;
}
if (right_arrow(b)){
speed_x = 1;
direction = %01;
}else if (left_arrow(b)){
speed_x = -1;
direction = %10;
}
global_.isaac.speed = [speed_x, speed_y];
global_.isaac.direction = [global_.isaac.direction[7:3],direction]

// INIT AB
(0xFFEE) = %00010000; // select button keys
b = get_button_values();
// SET AB
if (A(b)) // bit $0,b
set(global_.isaac.tears.a);
else
res(global_.isaac.tears.a);
if (B(b)) // bit $0,a
set(global_.isaac.tears.b);
else
res(global_.isaac.tears.b);

~~~
* INIT ARROW: Set $FF00 to select the arrow keys.
* CHECK ARROWS: Set the speed and direction according to the key pressed.
* INIT AB: Set $FF00 to select the button keys.
* CHECK AB: Set the a/b flags according to the key pressed.
### Notes
### TODO
* In a future version, we will have to set the direction value too.
* Set the seep to other value when the speed upgrade is set.

0 comments on commit c5cdb11

Please sign in to comment.