rnes 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d3d1d154a09065286af7ca812325aa2b1685cbf
4
- data.tar.gz: cfa99900503dd5d59f6553f7ee3c81f4fd292dc3
3
+ metadata.gz: cf2afd8224c221333be85c60dddbdf47a355ca99
4
+ data.tar.gz: e8ff4cd2fe43280b24f9132a132eea289813f9bd
5
5
  SHA512:
6
- metadata.gz: 859089e4d81fb3888ea5e52b95de2695f48acf3346b219a5e579ebcdd6516ff92ce709a798334afc60e2adf76c078898d6d79fb866c8cb6659fff149360f983e
7
- data.tar.gz: 3e69abecdf78153e5ceca5090fbf8b6202fb936f710eb49a659a6b3d25756d4e52d245c93bbad73b4ca7ed8a55419b329276a6d97cf490ec4e1387be0b5ab187
6
+ metadata.gz: 4e19a94ab96f907994766631a5c9143998eb12e3b697c6ba9e728c2369dbd9d87838cc33f7b83d783b36215d52b5efacee20f6f473e9d5c25d5d0410279fb95c
7
+ data.tar.gz: 3bc697a23906996906f7a3ba7f697547a1280544105597aac986969687d29ea2c5166c962080dd62ab92aeee49669b31d96368ac34e5b2857eba16cf80c09a04
@@ -49,6 +49,9 @@ Style/GuardClause:
49
49
  Style/IfUnlessModifier:
50
50
  Enabled: false
51
51
 
52
+ Style/Next:
53
+ Enabled: false
54
+
52
55
  Style/TrailingCommaInArrayLiteral:
53
56
  EnforcedStyleForMultiline: comma
54
57
 
@@ -1,5 +1,24 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
1
8
  ## Unreleased
2
9
 
10
+ ## 0.2.1 - 2018-11-24
11
+
12
+ ### Added
13
+
14
+ - Decrease terminal renderer brightness threshold for better visibility.
15
+
16
+ ### Fixed
17
+
18
+ - Fix PPU unnecessary vertical offset on rendering sprites.
19
+ - Fix PPU background unused palette address redirection.
20
+ - Fix PPU sprite rendering about transparent color.
21
+
3
22
  ## 0.2.0 - 2018-11-17
4
23
 
5
24
  ### Added
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rnes (0.1.1)
4
+ rnes (0.2.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -5,6 +5,12 @@ require 'rnes/operation'
5
5
 
6
6
  module Rnes
7
7
  class Cpu
8
+ INTERRUPTION_VECTOR_FOR_IRQ_OR_BRK = 0xFFFE
9
+
10
+ INTERRUPTION_VECTOR_FOR_NMI = 0xFFFA
11
+
12
+ INTERRUPTION_VECTOR_FOR_RESET = 0xFFFC
13
+
8
14
  # @return [Rnes::CpuBus] bus
9
15
  attr_reader :bus
10
16
 
@@ -31,7 +37,7 @@ module Rnes
31
37
 
32
38
  def reset
33
39
  @registers.reset
34
- @registers.program_counter = read_word(0xFFFC)
40
+ @registers.program_counter = read_word(INTERRUPTION_VECTOR_FOR_RESET)
35
41
  end
36
42
 
37
43
  # @return [Integer]
@@ -369,7 +375,7 @@ module Rnes
369
375
  push(@registers.status)
370
376
  unless @registers.interrupt?
371
377
  @registers.interrupt = true
372
- @registers.program_counter = read_word(0xFFFE)
378
+ @registers.program_counter = read_word(INTERRUPTION_VECTOR_FOR_IRQ_OR_BRK)
373
379
  end
374
380
  @registers.program_counter -= 1
375
381
  end
@@ -1011,7 +1017,7 @@ module Rnes
1011
1017
  push_word(@registers.program_counter)
1012
1018
  push(@registers.status)
1013
1019
  @registers.interrupt = true
1014
- @registers.program_counter = read_word(0xFFFE)
1020
+ @registers.program_counter = read_word(INTERRUPTION_VECTOR_FOR_IRQ_OR_BRK)
1015
1021
  end
1016
1022
 
1017
1023
  def handle_nmi
@@ -1020,7 +1026,7 @@ module Rnes
1020
1026
  push_word(@registers.program_counter)
1021
1027
  push(@registers.status)
1022
1028
  @registers.interrupt = true
1023
- @registers.program_counter = read_word(0xFFFA)
1029
+ @registers.program_counter = read_word(INTERRUPTION_VECTOR_FOR_NMI)
1024
1030
  end
1025
1031
 
1026
1032
  # @return [Integer]
@@ -202,13 +202,6 @@ module Rnes
202
202
  (x_of_block.even? ? 0 : 1) + (y_of_block.even? ? 0 : 2)
203
203
  end
204
204
 
205
- # @return [Integer] Integer from 0 to 63.
206
- def object_attribute_index
207
- (y_of_encoded_attributes % ENCODED_ATTRIBUTES_COUNT_IN_VERTICAL_LINE) * ENCODED_ATTRIBUTES_COUNT_IN_HORIZONTAL_LINE +
208
- x_of_encoded_attributes % ENCODED_ATTRIBUTES_COUNT_IN_HORIZONTAL_LINE +
209
- background_pattern_index_paging_offset
210
- end
211
-
212
205
  def check_sprite_hit
213
206
  if read_from_sprite_ram(0) == y && @registers.background_enabled? && @registers.sprite_enabled?
214
207
  registers.sprite_hit = true
@@ -233,12 +226,12 @@ module Rnes
233
226
  pattern_line_low_byte = read_background_pattern_line(pattern_line_low_byte_address)
234
227
  pattern_line_high_byte = read_background_pattern_line(pattern_line_low_byte_address + TILE_HEIGHT)
235
228
 
236
- mini_palette_ids_byte = read_object_attribute(object_attribute_index)
237
- mini_palette_id = (mini_palette_ids_byte >> (block_id_in_encoded_attributes * 2)) & 0b11
229
+ palette_ids_byte = read_object_attribute(object_attribute_index)
230
+ palette_id = (palette_ids_byte >> (block_id_in_encoded_attributes * 2)) & 0b11
238
231
 
239
232
  TILE_WIDTH.times do |x_in_pattern|
240
233
  index_in_pattern_line_byte = TILE_WIDTH - 1 - x_in_pattern
241
- background_palette_index = pattern_line_low_byte[index_in_pattern_line_byte] | (pattern_line_high_byte[index_in_pattern_line_byte] << 1) | (mini_palette_id << 2)
234
+ background_palette_index = pattern_line_low_byte[index_in_pattern_line_byte] | (pattern_line_high_byte[index_in_pattern_line_byte] << 1) | (palette_id << 2)
242
235
  color_id = read_color_id(background_palette_index)
243
236
  @image.write(
244
237
  value: ::Rnes::Ppu::COLORS[color_id],
@@ -263,13 +256,12 @@ module Rnes
263
256
  # `-------- vertical flip
264
257
  def draw_sprites
265
258
  0.step(SPRITES_COUNT - 1, 4) do |base_sprite_ram_address|
266
- y_for_sprite = (read_from_sprite_ram(base_sprite_ram_address) - TILE_HEIGHT)
267
- next if y_for_sprite.negative?
259
+ y_for_sprite = read_from_sprite_ram(base_sprite_ram_address)
268
260
  pattern_index = read_from_sprite_ram(base_sprite_ram_address + 1)
269
261
  sprite_attribute_byte = read_from_sprite_ram(base_sprite_ram_address + 2)
270
262
  x_for_sprite = read_from_sprite_ram(base_sprite_ram_address + 3)
271
263
 
272
- mini_palette_id = sprite_attribute_byte & 0b11
264
+ palette_id = sprite_attribute_byte & 0b11
273
265
  reversed_horizontally = sprite_attribute_byte[6] == 1
274
266
  reversed_vertically = sprite_attribute_byte[7] == 1
275
267
 
@@ -279,20 +271,29 @@ module Rnes
279
271
  pattern_line_high_byte = read_sprite_pattern_line(pattern_line_low_byte_address + TILE_HEIGHT)
280
272
  TILE_WIDTH.times do |x_in_pattern|
281
273
  index_in_pattern_line_byte = TILE_WIDTH - 1 - x_in_pattern
282
- background_palette_index = pattern_line_low_byte[index_in_pattern_line_byte] | pattern_line_high_byte[index_in_pattern_line_byte] << 1 | mini_palette_id << 2
283
- color_id = read_color_id(background_palette_index)
284
- y_in_pattern = TILE_HEIGHT - 1 - y_in_pattern if reversed_vertically
285
- x_in_pattern = TILE_WIDTH - 1 - x_in_pattern if reversed_horizontally
286
- @image.write(
287
- value: ::Rnes::Ppu::COLORS[color_id],
288
- x: x_for_sprite + x_in_pattern,
289
- y: y_for_sprite + y_in_pattern,
290
- )
274
+ sprite_palette_index = pattern_line_low_byte[index_in_pattern_line_byte] | (pattern_line_high_byte[index_in_pattern_line_byte] << 1) | (palette_id << 2)
275
+ if sprite_palette_index % 4 != 0
276
+ color_id = read_color_id(sprite_palette_index)
277
+ y_in_pattern = TILE_HEIGHT - 1 - y_in_pattern if reversed_vertically
278
+ x_in_pattern = TILE_WIDTH - 1 - x_in_pattern if reversed_horizontally
279
+ @image.write(
280
+ value: ::Rnes::Ppu::COLORS[color_id],
281
+ x: x_for_sprite + x_in_pattern,
282
+ y: y_for_sprite + y_in_pattern,
283
+ )
284
+ end
291
285
  end
292
286
  end
293
287
  end
294
288
  end
295
289
 
290
+ # @return [Integer] Integer from 0 to 63.
291
+ def object_attribute_index
292
+ (y_of_encoded_attributes % ENCODED_ATTRIBUTES_COUNT_IN_VERTICAL_LINE) * ENCODED_ATTRIBUTES_COUNT_IN_HORIZONTAL_LINE +
293
+ x_of_encoded_attributes % ENCODED_ATTRIBUTES_COUNT_IN_HORIZONTAL_LINE +
294
+ background_pattern_index_paging_offset
295
+ end
296
+
296
297
  # @return [Boolean]
297
298
  def on_bottom_end_line?
298
299
  line == WINDOW_HEIGHT + V_BLANK_HEIGHT
@@ -24,6 +24,8 @@ module Rnes
24
24
  read(address - 0x0800)
25
25
  when 0x3000..0x3EFF
26
26
  read(address - 0x1000)
27
+ when 0x3F04, 0x3F08, 0x3F0C
28
+ read(0x3F00)
27
29
  when 0x3F10, 0x3F14, 0x3F18, 0x3F1C
28
30
  read(address - 0x0010)
29
31
  when 0x3F00..0x3F1F
@@ -6,7 +6,7 @@ module Rnes
6
6
 
7
7
  BRAILLE_WIDTH = 2
8
8
 
9
- BRIGHTNESS_SUM_THRESHOLD = 128 * 3
9
+ BRIGHTNESS_SUM_THRESHOLD = 256
10
10
 
11
11
  TEXT_HEIGHT = 61
12
12
 
@@ -1,3 +1,3 @@
1
1
  module Rnes
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.2.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rnes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-17 00:00:00.000000000 Z
11
+ date: 2018-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler